The attached Triple.i, when compiled with `g++ -c -O2 -Wstrict-aliasing
Triple.i`, returns:

Triple.i: In function 'void setOSName(const StringRef&)':
Triple.i:9: warning: dereferencing pointer '<anonymous>' does break
strict-aliasing rules
Triple.i:9: note: initialized from here

Line 9 is:
if (LHSKind == TwineKind) return static_cast<const Twine *>(LHS)->LHSKind;
I believe the warning is incorrect since when LHSKind == TwineKind, LHS is only
assigned a Twine*. There's no aliasing through the void*. (And in this
subprogram, LHSKind is in fact never ==TwineKind.)

The warning goes away if I delete the __builtin_expect.

$ g++ -v
Using built-in specs.
Target: i386-apple-darwin9
Configured with: ../gcc-4.4.1/configure --prefix=/opt/local
--build=i386-apple-darwin9 --enable-languages=c,c++,objc,obj-c++,java,fortran
--libdir=/opt/local/lib/gcc44 --includedir=/opt/local/include/gcc44
--infodir=/opt/local/share/info --mandir=/opt/local/share/man
--with-local-prefix=/opt/local --with-system-zlib --disable-nls
--program-suffix=-mp-4.4 --with-gxx-include-dir=/opt/local/include/gcc44/c++/
--with-gmp=/opt/local --with-mpfr=/opt/local
Thread model: posix
gcc version 4.4.1 (GCC)


-- 
           Summary: Incorrect "dereferencing pointer '<anonymous>' does
                    break strict-aliasing rules"
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jyasskin at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41838

Reply via email to