dereferencing type-punned pointer will break strict-aliasing rules

Marc Lehmann schmorp at
Sat Oct 11 16:33:42 CEST 2008

> Now, my problem:
> ev.c: In Funktion »main«:
> ev.c:45: Warnung: Dereferenzierung eines Type-Pun-Zeigers verletzt  
> strict-aliasing-Regeln

This is a bug in your compiler, please read the warnings section of the
libev documentation for details.

> Problem is, I tend to use -Wall -Werror, as the compiler is my friend  

-Werror is a pretty stupid idea, it breaks correct programs needlessly. You
are free to use it on your programs, but using it on other programs is not a
bright idea.

> and it usually pays of taking care if he complains, therefore I can't  
> compile code with libev timers.

libev was written in C, if you use a compiler for a different language,
then such probelms are expected.

> Of course I could use -fno-strict-aliasing, but that does not fix the  
> problems root cause.

-fno-strict-aliasing is completely irrelevant to the problem, as it does
not fix anything, it only switches the compiler into a mode where it
accepts broken programs with some guarentees on making them work. This is
not necessary for libev, although it won't break it as it works in both

> For now I'll have to disable -Werror, but I'd prefer a real working  
> solution.

The real working solution is using a C compiler for C programs.

                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_    
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      pcg at
      -=====/_/_//_/\_,_/ /_/\_\

More information about the libev mailing list