This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
optimization/2131: Wrong result upon returning long long value
- To: gcc-gnats at gcc dot gnu dot org
- Subject: optimization/2131: Wrong result upon returning long long value
- From: nenad at tensilica dot com
- Date: 1 Mar 2001 01:01:58 -0000
- Reply-To: nenad at tensilica dot com
>Number: 2131
>Category: optimization
>Synopsis: Wrong result upon returning long long value
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Feb 28 17:06:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: nenad@tensilica.com
>Release: gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
When the attached C++ file is compiled with -O3 (or higher)
the result is incorrect:
[1 1074856072 56]
Without optimization or with -O1 the result is correct:
[1 234 56]
The assembly code after the call to get_srcpos looks wrong:
call get_srcpos__Fv
movl %eax,-8(%ebp)
leal -8(%ebp),%eax
movl 4(%eax),%ebx
movl %edx,-4(%ebp)
Value stored into %ebx should come from %edx (via -4(%ebp)),
but the scheduler seems to have rearranged those two instructions
incorrectly.
>How-To-Repeat:
% gcc -O2 bug.cxx
% a.out
[1 -1073743680 56]
% gcc bug.cxx
% a.out
[1 234 56]
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="bug.cxx"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="bug.cxx"
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRpbnQuaD4KCnN0YXRpYyBGSUxFICpmaWxl
ID0gc3Rkb3V0OwoKc3RydWN0IHNyY3Bvc190IHsKICB1aW50MTZfdCBmaWxlbnVtOwogIHVpbnQx
Nl90IGNvbHVtbjsKICBpbnQzMl90IGxpbmVudW07Cn07CgpzdGF0aWMgdWludDY0X3QKZ2V0X3Ny
Y3BvcygpCnsKICBzcmNwb3NfdCBkID0gezEsNTYsMjM0fTsKICB1aW50NjRfdCAqcCA9ICh1aW50
NjRfdCopJmQ7CiAgcmV0dXJuICpwOwp9CgptYWluKCkKewogIHVpbnQ2NF90IHNyY3BvcyA9IGdl
dF9zcmNwb3MoKTsKICBpbnQgbGluZW5vID0gKChzcmNwb3NfdCopJnNyY3BvcyktPmxpbmVudW0g
OwogIGlmIChmaWxlKSB7CiAgICBpbnQgZmlsZW5vID0gKChzcmNwb3NfdCopJnNyY3BvcyktPmZp
bGVudW07CiAgICBpbnQgY29sbm8gPSAoKHNyY3Bvc190Kikmc3JjcG9zKS0+Y29sdW1uOwogICAg
ZnByaW50ZihmaWxlLCAiWyVkICVkICVkXVxuIiwgZmlsZW5vLCBsaW5lbm8sIGNvbG5vKTsKICB9
Cn0K