I did look at those strict aliasing warnings a while back.  It seemed
to me that they're not bugs.

They're caused by the header declaring structures (specifically ev_*
and ev_watcher) that start with some common elements, casting a
pointer to one to a pointer top the other, and accessing the common
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
that isn't likely to happen on any real system (which has abi rules so
different compilers can interoperate).  In theory, one could avoid
these warnings by having the larger structures have the smaller
structures as their first member, not just sharing their first
members, but that might make the code uglier and is not worth imo.
(The strange thing is that in some places the ev.h header actually has
code to silence these same warnings, such as in the ev_init macro.)

The warnings are a bit annoying because they appear in user code that
expand macros from the ev.h header, and with gcc they were not
specific enough for me to easily tell that these are indeed caused by
the header doing these casts, not something in my code.

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 --
I don't quite understand the rules, but then I don't understand the
rules that allow the double meaning of std::clog either.

Ambrus

_______________________________________________
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev

Reply via email to