Bug 486176

Summary: #pragma GCC optimize("no-strict-aliasing") does not work
Product: [Fedora] Fedora Reporter: Kevin Kofler <kevin>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: jakub, rdieter
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-02-18 19:14:16 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Kevin Kofler 2009-02-18 19:05:24 UTC
Description of problem:
#pragma GCC optimize("no-strict-aliasing") appears to have no effect, as aliasing warnings are still output when compiling a file with:
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
#pragma GCC optimize("no-strict-aliasing")
#endif
at the beginning. No warnings are issued about the pragma being ignored either.

Version-Release number of selected component (if applicable):
gcc-4.4.0-0.20

How reproducible:
Always.

Steps to Reproduce:
1. Try building kdelibs-4.2.0-12.fc11 or just look at the build logs from my build.
  
Actual results:
Aliasing warnings still present in kjs/dtoa.cpp.

Expected results:
No aliasing warnings in kjs/dtoa.cpp.

Additional info:
kdelibs-4.2.0-13.fc11 now simply adds -fno-strict-aliasing on the command line through CMake, which works, so this is not urgent for us, but it seems to indicate something being broken in the #pragma GCC optimize machinery.

Comment 1 Jakub Jelinek 2009-02-18 19:14:16 UTC
That's not a bug, but feature.  The ability to tweak strict-aliasing using optimize attribute/pragma lead to many ICEs and has been disabled on purpose, see
http://gcc.gnu.org/PR37106.

That said, just being lazy and using -fno-strict-aliasing is the wrong thing to do, much better is to actually look at the code and fix the bugs in it, submit upstream.

Comment 2 Kevin Kofler 2009-02-18 19:42:09 UTC
But should GCC not at least warn that the #pragma (or rather its value) is being ignored?