[PATCH 2] fix broken strict aliasing

Alejandro Mery amery at geeks.cl
Fri Feb 19 19:14:28 CET 2010


Hi again,

On 19/02/10 18:39, Marc Lehmann wrote:
> On Fri, Feb 19, 2010 at 06:26:49PM +0100, Alejandro Mery<amery at geeks.cl>  wrote:
>> what's the danger? why do you insist in refusing this?
>
> a compiler might well find an aliasing issue with the existing code, but
> unlikely with the patch.
>
>> "at best" they reduce tons of warnings without affecting the code.
>
> if you get tons of warnings then your compiler or config is broken, and this
> is certainly the exception.
>
>> what's wrong with the warnings?
>
> good question, I don't get any warnings, and libev doesn't generate them.
>
> so you need to identify where the warnings originate (e..g in your
> compiler) and then ask this question to those people who actually control
> the code that generates such bogus warnings.
>
>> they add tons of noise that doesn't
>> allow us to see clearly other warnings that can be interesting.
>
> exactly...
>
> but this really is out of the scope for libev, as libev doesn't generate
> those warnings.
>

ok, simple test case. (yes, it's "only warnings", but they distract 
a LOT)

$ grep -n ^ test.c
1:#include <ev.h>
2:#include <stdio.h>
3:
4:static void stdin_cb(struct ev_loop *loop, ev_io *w, int revents)
5:{
6:	puts("stdin ready\n");
7:	ev_io_stop(loop, w);
8:	ev_unloop(loop, EVUNLOOP_ALL);
9:}
10:
11:int main(void)
12:{
13:	struct ev_loop *loop = ev_default_loop(0);
14:	ev_io stdin_watcher;
15:
16:	ev_io_init(&stdin_watcher, stdin_cb, 0, EV_READ);
17:	ev_io_start(loop, &stdin_watcher);
18:
19:	ev_loop(loop, 0);
20:
21:	return 0;
22:}

$ gcc -W -Wall -O2 -o test -lev test.c
test.c: In function ‘stdin_cb’:
test.c:4: warning: unused parameter ‘revents’
test.c: In function ‘main’:
test.c:16: warning: dereferencing type-punned pointer will break 
strict-aliasing rules
test.c:16: warning: dereferencing type-punned pointer will break 
strict-aliasing rules
test.c:16: warning: dereferencing type-punned pointer will break 
strict-aliasing rules
test.c:16: warning: dereferencing pointer ‘stdin_watcher.22’ does 
break strict-aliasing rules
test.c:16: warning: dereferencing pointer ‘stdin_watcher.22’ does 
break strict-aliasing rules
test.c:16: warning: dereferencing pointer ‘stdin_watcher.22’ does 
break strict-aliasing rules
test.c:16: warning: dereferencing pointer ‘stdin_watcher.22’ does 
break strict-aliasing rules
test.c:16: warning: dereferencing pointer ‘stdin_watcher.22’ does 
break strict-aliasing rules
test.c:16: note: initialized from here

$ gcc --version
gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1

Regards,
Alejandro Mery

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5215 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20100219/3a0599ec/attachment.bin>


More information about the libev mailing list