[ros-kernel] Re: [ros-cvs] CVS Update: reactos

Alex Ionescu ionucu at videotron.ca
Wed Aug 4 11:24:17 CEST 2004


If you'd like to help fix the aliasing rules (which would require re-writing
a lot of function prototypes, or use tricky typecasting "hacks"), we'd
welcome that. Optimized builds are for releases and speed for now anyways,
so any debugging is usually done on non-optimized builds.

Thanks for your insight however.

Best regards,
Alex Ionescu

-----Original Message-----
From: ros-kernel-bounces at reactos.com [mailto:ros-kernel-bounces at reactos.com]
On Behalf Of d_layer
Sent: Wednesday, August 04, 2004 4:46 AM
To: ros-kernel at reactos.com; navaraf at osexperts.com
Subject: [ros-kernel] Re: [ros-cvs] CVS Update: reactos

If you really want to use -fstrict-aliasing, you must fix the
source code to comply with the strict-aliasing rules.
Specifying -Wno-strict-aliasing does not help.

Because warnings enabled by -Wstrict-aliasing mean "your code is
breaking the strict-aliasing rules, so gcc may misoptimize your code,"
ignoring these warnings while specifying -O2 (-fstrict-aliasing)
might cause you to suffer from mysterious bugs.

The strict-aliasing rules are explained in section "6.5  Expressions",
paragraph #7 of the C99 draft standard:
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n869/n869.txt.gz
(older ANSI/ISO C standards have essentially the same rules)

The following source code demonstrates the effect of optimizations
based on the strict-aliasing rules. It prints "0" or "65536" when
compiled with "gcc -O2" or "gcc -O2 -fno-strict-aliasing", respectively.
confirmed with gcc 3.3.3/i386.
----- cut here -----
#include <stdio.h>
int main(void) { int packed = 0; *((short *)&packed+1) = 1; printf("%d\n",
packed); return 0; }
----- cut here -----

-- 
d_layer

navaraf at osexperts.com wrote:
> CVSROOT: /CVS/ReactOS
> Module name: reactos
> Repository: reactos/ntoskrnl/
> Changes by: navaraf at mok.osexperts.com 04/08/03 19:27:07
> 
> Modified files:
> reactos/ntoskrnl/: Makefile 
> 
> Log message:
> - Change -fno-strict-aliasing to -Wno-strict-aliasing for optimized
builds.

_______________________________________________
Ros-kernel mailing list
Ros-kernel at reactos.com
http://reactos.com/mailman/listinfo/ros-kernel



More information about the Ros-kernel mailing list