Bug 38169 - Wrong string constant optimizing
Summary: Wrong string constant optimizing
Status: RESOLVED DUPLICATE of bug 38051
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.0
Assignee: Richard Biener
URL:
Keywords: alias, wrong-code
Depends on:
Blocks:
 
Reported: 2008-11-17 13:08 UTC by Holger Hopp
Modified: 2008-11-20 12:15 UTC (History)
5 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2008-11-17 20:34:53


Attachments
testcase (2.28 KB, text/x-csrc)
2008-11-17 13:09 UTC, Holger Hopp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Holger Hopp 2008-11-17 13:08:25 UTC
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)
Comment 1 Holger Hopp 2008-11-17 13:09:21 UTC
Created attachment 16709 [details]
testcase
Comment 2 Richard Biener 2008-11-17 18:20:39 UTC
Maybe related to PR38051 - I cannot reproduce the problem after that rev.

Can you double-check?
Comment 3 Richard Biener 2008-11-17 20:34:22 UTC
Patch for 4.3: http://gcc.gnu.org/ml/gcc-patches/2008-11/msg00830.html
Comment 4 Holger Hopp 2008-11-18 11:01:48 UTC
Indeed, the newest trunk rev. fixed that issue. Great!
Comment 5 Richard Biener 2008-11-20 12:15:37 UTC
Fixed.

*** This bug has been marked as a duplicate of 38051 ***