Bug 47708 - incorrect code on -O2 without -fno-tree-pre
Summary: incorrect code on -O2 without -fno-tree-pre
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.5.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-12 06:27 UTC by zephyrtronium
Modified: 2011-02-12 07:26 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
minimal case (187 bytes, text/plain)
2011-02-12 06:27 UTC, zephyrtronium
Details

Note You need to log in before you can comment on or make changes to this bug.
Description zephyrtronium 2011-02-12 06:27:22 UTC
Created attachment 23310 [details]
minimal case

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.5.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.5.2/configure --enable-lto
Thread model: posix
gcc version 4.5.2 (GCC)

Compiling the following minimal case on -O2 or -O3 and running results in incorrect output; with -O0, -O1, or -Os, it is correct. -O2 -fno-tree-pre results in correct output, but -O1 -ftree-pre is also correct. GCC 4.4.3 appears to work.
Comment 1 pinskia@gmail.com 2011-02-12 06:36:09 UTC
You are violating c/c++ aliasing rules.  The code is undefined.



Sent from my Palm Pre on AT&T
On Feb 11, 2011 22:27, zephyrtronium at gmail dot com <gcc-bugzilla@gcc.gnu.org> wrote: 

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



           Summary: incorrect code on -O2 without -fno-tree-pre

           Product: gcc

           Version: 4.5.2

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: tree-optimization

        AssignedTo: unassigned@gcc.gnu.org

        ReportedBy: zephyrtronium@gmail.com





Created attachment 23310 [details]

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23310

minimal case



gcc -v

Using built-in specs.

COLLECT_GCC=gcc

COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.5.2/lto-wrapper

Target: x86_64-unknown-linux-gnu

Configured with: ../gcc-4.5.2/configure --enable-lto

Thread model: posix

gcc version 4.5.2 (GCC)



Compiling the following minimal case on -O2 or -O3 and running results in

incorrect output; with -O0, -O1, or -Os, it is correct. -O2 -fno-tree-pre

results in correct output, but -O1 -ftree-pre is also correct. GCC 4.4.3

appears to work.
Comment 2 Andrew Pinski 2011-02-12 07:26:12 UTC
You are accessing a long long via a short.  If you accessed it via a char, that would not violate aliasing rules though.

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