libalias patch for review / testing

Ruslan Ermilov ru at freebsd.org
Tue Mar 16 15:28:47 PST 2004


On Wed, Mar 17, 2004 at 12:07:52AM +0100, Dag-Erling Sm?rgrav wrote:
> Ruslan Ermilov <ru at FreeBSD.org> writes:
> > I know this code quite well.  Where do you suspect could be a bug
> > affecting -O2 compiles, or you just simply fixed -O2 and hope it
> > will auto-fix the (possible) bugs in -O2?
> 
> Since there is no inline asm, the most likely suspect is aliasing,
> which is what my patch tries to address.
> 
Hmm, read this again:

: `-fstrict-aliasing'
:      Allows the compiler to assume the strictest aliasing rules
:      applicable to the language being compiled.  For C (and C++), this
:      activates optimizations based on the type of expressions.  In
:      particular, an object of one type is assumed never to reside at
:      the same address as an object of a different type, unless the
:      types are almost the same.  For example, an `unsigned int' can
:      alias an `int', but not a `void*' or a `double'.  A character type
:      may alias any other type.

And asking myself a question: should those (void *)'s in your patch
be (char *)'s instead, e.g., in twowords() and DifferentialChecksum(),
or am I misreading the above?

Also, the easiest way to check if strict aliasing is guilty for not
working libalias compiled with -O2, is to compile the original code
with -O2 -fno-strict-aliasing.  You guys who have seen a problem,
can you please check and confirm that?


Cheers,
-- 
Ruslan Ermilov
FreeBSD committer
ru at FreeBSD.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-net/attachments/20040317/f67b6c3f/attachment.bin


More information about the freebsd-net mailing list