Red Hat Bugzilla – Bug 486176
#pragma GCC optimize("no-strict-aliasing") does not work
Last modified: 2009-02-18 14:42:09 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")
at the beginning. No warnings are issued about the pragma being ignored either.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Try building kdelibs-4.2.0-12.fc11 or just look at the build logs from my build.
Aliasing warnings still present in kjs/dtoa.cpp.
No aliasing warnings in kjs/dtoa.cpp.
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.
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
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.
But should GCC not at least warn that the #pragma (or rather its value) is being ignored?