This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/38169] New: Wrong string constant optimizing


I have found a bug in string constant optimizing in gcc-4.4 trunk.
It occurs with -O3 or -O2 -profile-generate (tested on x86_64 and ia64).
For C the problem is fixed since rev. 141606, but not for C++.
Tested rev. 141852.

g++ is okay with non-static function (set -DNO_STATIC):

$ ./g++-4.4-141852 -std=c++0x -DNO_STATIC -O3 testutf3.c -o testutf3 &&
./testutf3
Test OK

g++ -O2 is also okay with static functions:
$ ./g++-4.4-141852 -std=c++0x -O2 testutf3.c -o testutf3 && ./testutf3
Test OK


g++ is not okay with static functions using -O3 or -O2 -fprofile-generate:

$ ./g++-4.4-141852 -std=c++0x -O3 testutf3.c -o testutf3 && ./testutf3
Verify ws failed. Expected: Hello World L Got: 95ad96f8  2a   0   19566cdd0 
2abffff388  7f9566ca88  2a4003ec   0bffff408
Verify Us failed. Expected: Hello World U Got: 95579ab0  2a9555d724  2a95579ab0
 2a   1  2a   0   0   1  2a   1
Verify ws failed. Expected: HelloWorld s L Got: 95ad96f8  2a   0   19566cdd0 
2abffff388  7f9566ca88  2a4003ec   0bffff408  7f
Verify Us failed. Expected: HelloWorld s U Got: 95579ab0  2a9555d724 
2a95579ab0  2a   1  2a   0   0   1  2a   1   0
Verify ws failed. Expected: HelloWorld L s Got: 95ad96f8  2a   0   19566cdd0 
2abffff388  7f9566ca88  2a4003ec   0bffff408  7f
Verify Us failed. Expected: HelloWorld U s Got: 95579ab0  2a9555d724 
2a95579ab0  2a   1  2a   0   0   1  2a   1   0
Test FAILED. 6 failures occured
Aborted
Exit 134 (SIGABRT)
$ g++-4.4-141852 -std=c++0x -O2 -fprofile-generate testutf3.c -o testutf3 &&
./testutf3
Verify ws failed. Expected: Hello World L Got: 604340   09ccb80b1   0403779  
040352c   0   b   0402117   09566cdd0
Verify us failed. Expected: Hello World u Got: ca88 9566 2a  0 750 40  0  0
4000 60  0  0 f2e0
Verify Us failed. Expected: Hello World U Got: 604340   095560ef2  2a604328   0
  0   0   0   0   0   0402630
Verify ws failed. Expected: HelloWorld s L Got: 604340   09ccb80b1   0403779  
040352c   0   b   0402117   09566cdd0  2a
Verify us failed. Expected: HelloWorld s u Got: ca88 9566 2a  0 750 40  0  0
4000 60  0  0 f2e0 bfff
Verify Us failed. Expected: HelloWorld s U Got: 604340   095560ef2  2a604328  
0   0   0   0   0   0   0402630   0
Verify ws failed. Expected: HelloWorld L s Got: 604340   09ccb80b1   0403779  
040352c   0   b   0402117   09566cdd0  2a
Verify us failed. Expected: HelloWorld u s Got: ca88 9566 2a  0 750 40  0  0
4000 60  0  0 f2e0 bfff
Verify Us failed. Expected: HelloWorld U s Got: 604340   095560ef2  2a604328  
0   0   0   0   0   0   0402630   0
Verify us failed. Expected: Hello World Got: 6548 6c6c 206f 6f57 6c72 64  0  0 
1  0 2a
Verify us failed. Expected:  Hello World Got: ca88 9566 2a  0 750 40  0  0 4000
60  0  0
Test FAILED. 11 failures occured
Aborted
Exit 134 (SIGABRT)


gcc is okay since trunk rev. 141606 with and non-static functions (set
-DNO_STATIC):

$ gcc-4.4-141852 -std=gnu99 -DNO_STATIC -O3 testutf3.c -o testutf3 &&
./testutf3
Test OK
$ gcc-4.4-141852 -std=gnu99 -O3 testutf3.c -o testutf3 && ./testutf3
Test OK


gcc old rev. 141605 was not okay:

$ gcc-4.4-141605 -std=gnu99 -O3 testutf3.c -o testutf3 && ./testutf3
Verify ws failed. Expected: Hello World L Got:    0   0   0   0   05f363878   0
  19566cdd0  2abffff388  7f9566ca88
Verify Us failed. Expected: Hello World U Got:    0   0177ff8e   09556bba0 
2a9555d724  2a9556bba0  2a   143545520   0
[...]
Test FAILED. 9 failures occured
Aborted
Exit 134 (SIGABRT)
$ gcc-4.4-141605 -std=gnu99 -O2 -fprofile-generate testutf3.c -o testutf3 &&
./testutf3
Verify ws failed. Expected: Hello World L Got:    0   0   0   0402700  
09569dea1  2a604300   09ccb80b1   0403849
Verify us failed. Expected: Hello World u Got: ca88 9566 2a  0 6c8 40  0  0
4000 60  0  0 f2e0
[...]
Test FAILED. 13 failures occured
Aborted
Exit 134 (SIGABRT)


-- 
           Summary: Wrong string constant optimizing
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: holger dot hopp at sap dot com
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]