Bug 486176 - #pragma GCC optimize("no-strict-aliasing") does not work
Summary: #pragma GCC optimize("no-strict-aliasing") does not work
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: rawhide
Hardware: x86_64
OS: Linux
low
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-02-18 19:05 UTC by Kevin Kofler
Modified: 2009-02-18 19:42 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-02-18 19:14:16 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

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?


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