[PATCH 2] fix broken strict aliasing

Marc Lehmann schmorp at schmorp.de
Sun Feb 21 10:47:33 CET 2010

On Sat, Feb 20, 2010 at 06:20:26PM +0100, Zsbán Ambrus <ambrus at math.bme.hu> wrote:
> elements that way.  The compiler warns about that because the C
> standard doesn't guarantee that the rest of the elements of the struct
> doesn't change how the first elements are laid out in the struct, but

To the contrary, the C standard guarantees just that, and gcc follows it.
Seearch for common initial sequence.

Think about it, if the C standard didn't make that guarantee, unions would
be mostly useless.

Don't make so certain statements about the C standard if you don't really
know it - you are doing a disservice to anybody else who might be stupid
enough to blindly believe you.

(Sorry to be so explicit, but I get really annoyed when people argue with
made-up arguments like yours - check your facts, this is easy enough to

> that isn't likely to happen on any real system (which has abi rules so
> different compilers can interoperate).  In theory, one could avoid

It cannot happen on any system, real or theoretic, as long as it
implements C.

> Incidentally, what bothers me more than these aliasing warnings is
> that there's both a structure called struct ev_loop and a function
> called ev_loop in the same header.  Apparently C++ does allow this --

C allows it as well of course. I am not swure what others you, but the
struct tag namespace and the function identifier namespace are distinct in
both languages, and have been that way forever.

Of course, if standard C (or C++) bothers you, maybe you could interest
yourself with the perl interface, which has simpler scoping rules, albeit
Perl has never been standardised.

                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\

More information about the libev mailing list