hurd-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(no) strict aliasing


From: Marcus Brinkmann
Subject: (no) strict aliasing
Date: Sun, 31 Oct 2004 21:28:46 +0100
User-agent: Wanderlust/2.10.1 (Watching The Wheels) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/21.3 (i386-pc-linux-gnu) MULE/5.0 (SAKAKI)

Hi,

(tell me if you need an explanation of strict aliasing.  I'll do my
best to give a summary then.  I guess Roland will necessarily be
familiar with it due to his glibc related work.)

the code in pfinet relies (presumably) on -fno-strict-aliasing being
used (there is a comment indicating this in
pfinet/linux-src/include/net/tcp.h).

Even the function ports_create_port violates strict aliasing
semantics.  It will work fine for now on GCC, I guess, because you
cross source files in invoking it.  But if GCC were to do global alias
optimization in the future, such code could break.

The only way I found to make allocators like ports_create_port to
reliably work without disabling aliasing alltogether would be to have
the function return void * and use the __malloc__ function attribute.

There are likely other places in the code where pointers are cast
between superficially incompatible types with at least partially
compatible underlying representation of the object.  All such places
would violate strict aliasing rules, and can not really be fixed (in
the case of pointers cast, not even the union trick would do).

I am hitting similar problems in the code I write for the L4 port.  I
was wondering what you think about it -- if we should disable strict
aliasing globally, or fix such code individually.

Thanks,
Marcus





reply via email to

[Prev in Thread] Current Thread [Next in Thread]