I've come across an issue when using the latest libev with gcc 5.3.0
under RedHat 6 and 7.  It can be narrowed down to the following code:
$ cat /tmp/test.cpp
#include <ev++.h>
int main() {}
$ g++ -O2 -Wall -Wextra -Werror -I libev-4.22 -c /tmp/test.cpp
In file included from libev-4.22/ev++.h:46:0,
                 from /tmp/test.cpp:1:
libev-4.22/ev++.h: In member function ‘void ev::timer::set(ev_tstamp,
ev_tstamp)’:
libev-4.22/ev.h:694:76: error: dereferencing type-punned pointer will
break strict-aliasing rules [-Werror=strict-aliasing]
 #define ev_timer_set(ev,after_,repeat_)      do { ((ev_watcher_time
*)(ev))->at = (after_); (ev)->repeat = (repeat_); } while (0)
                                                                            ^
libev-4.22/ev++.h:643:7: note: in expansion of macro ‘ev_timer_set’
       ev_timer_set (static_cast<ev_timer *>(this), after, repeat);
       ^
cc1plus: all warnings being treated as errors

I can get around the issue by changing the optimization flag to -O1,
but I've also changed the following to allow -O2 and -O3:

--- ev.h.std 2016-07-04 11:00:06.443217000 +0100
+++ ev.h 2016-07-04 11:00:43.044330000 +0100
@@ -691,7 +691,7 @@
 } while (0)

 #define ev_io_set(ev,fd_,events_)            do { (ev)->fd = (fd_);
(ev)->events = (events_) | EV__IOFDSET; } while (0)
-#define ev_timer_set(ev,after_,repeat_)      do { ((ev_watcher_time
*)(ev))->at = (after_); (ev)->repeat = (repeat_); } while (0)
+#define ev_timer_set(ev,after_,repeat_)      do { void *tmp = (void
*)ev; ((ev_watcher_time *)(tmp))->at = (after_); (ev)->repeat =
(repeat_); } while (0)
 #define ev_periodic_set(ev,ofs_,ival_,rcb_)  do { (ev)->offset =
(ofs_); (ev)->interval = (ival_); (ev)->reschedule_cb = (rcb_); }
while (0)
 #define ev_signal_set(ev,signum_)            do { (ev)->signum =
(signum_); } while (0)
 #define ev_child_set(ev,pid_,trace_)         do { (ev)->pid = (pid_);
(ev)->flags = !!(trace_); } while (0)

_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/mailman/listinfo/libev

Reply via email to