This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Linux getdents.c is not aliasing safe

Daniel Jacobowitz <> writes:

> On Tue, Oct 29, 2002 at 11:33:49PM +0100, Andreas Schwab wrote:
> That works, patch attached.  With this I can use -O2 on i386 again -
> it's not a pretty patch but it does work at least :) My understanding
> is that this uses a GCC extension which says that accesses through a
> union may alias either member - does anyone know a standard C way of
> dealing with this situation?
> [That is: two pointers to a buffer, of different types; walk through
> the buffer, reading one object of the first type and writing out an
> object of the second lesser-or-equal sized type.]

No, there's no standard C way to do that.  An object can only have one
type at a time.  You have to use another buffer as an intermediate.

> At least in a compiler without any interprocedural optimization you
> could do this by having a function to convert one object.  If the
> function was inlined, would we have the same problem again someday?


- Geoffrey Keating <>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]