Bug 486176 - #pragma GCC optimize("no-strict-aliasing") does not work
#pragma GCC optimize("no-strict-aliasing") does not work
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
rawhide
x86_64 Linux
low Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-02-18 14:05 EST by Kevin Kofler
Modified: 2009-02-18 14:42 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-02-18 14:14:16 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Kevin Kofler 2009-02-18 14:05:24 EST
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 14:14:16 EST
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 14:42:09 EST
But should GCC not at least warn that the #pragma (or rather its value) is being ignored?

Note You need to log in before you can comment on or make changes to this bug.