Michal, I called it a bug because it is a C99 violation (ISO C99 edition, section 6.5, paragraph 7 specifies that it is illegal - with exceptions - for pointers of different types to reference the same memory location) and AFAIK the ast sources should be C99 clean to allow maximum portability, across all platforms involved. Being C99 clean is a requirement for Solaris too.
Olga On Wed, Feb 29, 2012 at 8:49 AM, Michal Hlavinka <[email protected]> wrote: > On 02/28/2012 08:32 PM, ольга крыжановская wrote: >> >> Michal, why are you comiling with -fno-strict-aliasing? Any problems >> with C aliasing should IMO be reported as bugs and fixed quickly, >> because it causes trouble with other platforms and portabilty. > > > Why? Because of this: > > warning: dereferencing type-punned pointer will break strict-aliasing rules > > If some optimization can't be used, it should be turned off. > > Why do you think it's a bug? > """ > -fstrict-aliasing > Allow the compiler to assume the strictest aliasing rules > applicable to the language being compiled. For C (and C++), this ctivates > optimizations based on the type of expressions. > """ > > The code is still valid and works as expected. Only some type of > optimization can't be used. Maybe it's an annoyance, but I won't call it a > bug. > > >> >> The warnings in your mail, which gcc and ast-open version did you use? >> I tested with Suse 12.1, gcc (SUSE Linux) 4.6.2, ast-open.2012-02-14 >> and only got this one warning >> src/lib/libast/vmalloc/vmstat.c: In function 'vmstat': >> src/lib/libast/vmalloc/vmstat.c:100:7: warning: dereferencing >> type-punned pointer will break strict-aliasing rules >> [-Wstrict-aliasing] >> >> Olga >> >> On Tue, Feb 28, 2012 at 3:59 PM, Michal Hlavinka<[email protected]> >> wrote: >>> >>> On 02/26/2012 01:29 PM, ольга крыжановская wrote: >>>> >>>> >>>> Glenn, I use a newer gcc version: gcc (SUSE Linux) 4.5.0 20100604 >>>> [gcc-4_5-branch revision 160292]. >>>> >>>> Can any one in the list confirm the warning with gcc>= 4.5? >>> >>> >>> >>> We use -fno-strict-aliasing for ksh compilation. I've turned it off and >>> got >>> this: >>> >>> src/lib/libast/vmalloc/vmbest.c:202:5: warning: dereferencing type-punned >>> pointer will break strict-aliasing rules >>> src/lib/libast/vmalloc/vmbest.c:440:4: warning: dereferencing type-punned >>> pointer will break strict-aliasing rules >>> src/lib/libast/vmalloc/vmbest.c:571:3: warning: dereferencing type-punned >>> pointer will break strict-aliasing rules >>> src/lib/libast/vmalloc/vmbest.c:682:3: warning: dereferencing type-punned >>> pointer will break strict-aliasing rules >>> src/lib/libast/vmalloc/vmbest.c:693:5: warning: dereferencing type-punned >>> pointer will break strict-aliasing rules >>> src/lib/libast/vmalloc/vmbest.c:694:5: warning: dereferencing type-punned >>> pointer will break strict-aliasing rules >>> src/lib/libast/vmalloc/vmopen.c:145:2: warning: dereferencing type-punned >>> pointer will break strict-aliasing rules >>> src/lib/libast/vmalloc/vmopen.c:150:2: warning: dereferencing type-punned >>> pointer will break strict-aliasing rules >>> src/lib/libast/vmalloc/vmopen.c:151:2: warning: dereferencing type-punned >>> pointer will break strict-aliasing rules >>> src/lib/libast/vmalloc/vmprivate.c:169:2: warning: dereferencing >>> type-punned >>> pointer will break strict-aliasing rules >>> >>> src/lib/libast/vmalloc/vmstat.c:100:7: warning: dereferencing type-punned >>> pointer will break strict-aliasing rules >>> src/lib/libast/vmalloc/vmstat.c:102:7: warning: dereferencing type-punned >>> pointer will break strict-aliasing rules >>> src/lib/libsum/sum-sha2.c:743:2: warning: dereferencing type-punned >>> pointer >>> will break strict-aliasing rules >>> src/lib/libsum/sum-sha2.c:1104:2: warning: dereferencing type-punned >>> pointer >>> will break strict-aliasing rules >>> src/lib/libsum/sum-sha2.c:1105:2: warning: dereferencing type-punned >>> pointer >>> will break strict-aliasing rules >>> src/cmd/ksh93/edit/emacs.c:1077:7: warning: dereferencing type-punned >>> pointer will break strict-aliasing rules >>> src/cmd/ksh93/edit/emacs.c:1079:7: warning: dereferencing type-punned >>> pointer will break strict-aliasing rules >>> >>> >>>> >>>> Olga >>>> >>>> On Sun, Feb 26, 2012 at 7:02 AM, Glenn Fowler<[email protected]> >>>> wrote: >>>>> >>>>> >>>>> >>>>> I don;t see this with >>>>> gcc version 4.3.4 [gcc-4_3-branch revision 152973] (SUSE Linux) >>>>> >>>>> On Wed, 15 Feb 2012 23:32:38 +0100 >>>>> =?KOI8-R?B?z8zYx8Egy9LZ1sHOz9fTy8HR?= >>>>> wrote: >>>>>> >>>>>> >>>>>> Glenn, in libast's vmalloc I get this warning if I compile libast on >>>>>> Suse Linux with gcc4 and CCFLAGS='-O3 -flto -fstrict-aliasing >>>>>> -Wstrict-aliasing': src/lib/libast/vmalloc/vmstat.c:100:7: warning: >>>>>> dereferencing type-punned pointer will break strict-aliasing rules >>>>>> This appears to be the only aliasing related warning. >>>>> >>>>> >>>>> >>>>>> Olga >>>>>> -- >>>>>> , _ _ , >>>>>> { \/`o;====- Olga Kryzhanovska -====;o`\/ } >>>>>> .----'-/`-/ [email protected] \-`\-'----. >>>>>> `'-..-| / http://twitter.com/fleyta \ |-..-'` >>>>>> /\/\ Solaris/BSD//C/C++ programmer /\/\ >>>>>> `--` `--` >>>>> >>>>> >>>>> >>>>>> _______________________________________________ >>>>>> ast-developers mailing list >>>>>> [email protected] >>>>>> https://mailman.research.att.com/mailman/listinfo/ast-developers >>>>> >>>>> >>>>> >>>> >>>> >>>> >>> >>> _______________________________________________ >>> ast-developers mailing list >>> [email protected] >>> https://mailman.research.att.com/mailman/listinfo/ast-developers >> >> >> >> > > _______________________________________________ > ast-developers mailing list > [email protected] > https://mailman.research.att.com/mailman/listinfo/ast-developers -- , _ _ , { \/`o;====- Olga Kryzhanovska -====;o`\/ } .----'-/`-/ [email protected] \-`\-'----. `'-..-| / http://twitter.com/fleyta \ |-..-'` /\/\ Solaris/BSD//C/C++ programmer /\/\ `--` `--` _______________________________________________ ast-developers mailing list [email protected] https://mailman.research.att.com/mailman/listinfo/ast-developers
