public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/47603] New: Optimization level O2 nad O3 produces different output from level O1 and O0
@ 2011-02-03 21:19 agamous at bgcpartners dot com
  2011-02-03 21:27 ` [Bug c++/47603] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: agamous at bgcpartners dot com @ 2011-02-03 21:19 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Optimization level O2 nad O3 produces different output
                    from level O1 and O0
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: agamous@bgcpartners.com
                CC: agamous@bgcpartners.com


Source code to compile 

#include <stdio.h>

int main()
{
    int i32 =0x12345678;

    short *t = (short *)&i32;
    t[0] = 0xaa;
    t[1] = 0xbb;

    printf("i32 = %lx\n", i32);
    return 0;
}

We tried both gcc and g++ with the same compilation options and the same
result.

Compilation line (optimization O3 or O2)
gcc -O3 -o foo foo.c
run as ./foo
output i32 = 12345678

If compiles with O1 or O0
gcc -O0 -o foo foo.c     
output i32 = bb00aa

GCC version
>       * the exact version of GCC, as shown by "gcc -v";
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
4.4.3-4ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--enable-shared --enable-multiarch --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4
--program-suffix=-4.4 --enable-nls --enable-clocale=gnu
--enable-libstdcxx-debug --enable-plugin --enable-objc-gc
--disable-werror --with-arch-32=i486 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 

CPU
Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz

system type 
uname -a displays the following
Linux 2.6.32-24-generic #39-Ubuntu SMP Wed Jul 28 05:14:15 UTC 2010
x86_64 GNU/Linux


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/47603] Optimization level O2 nad O3 produces different output from level O1 and O0
  2011-02-03 21:19 [Bug c++/47603] New: Optimization level O2 nad O3 produces different output from level O1 and O0 agamous at bgcpartners dot com
@ 2011-02-03 21:27 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-02-03 21:27 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-02-03 21:24:12 UTC ---
you are violating c/c++ aliasing rules.

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-02-03 21:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-03 21:19 [Bug c++/47603] New: Optimization level O2 nad O3 produces different output from level O1 and O0 agamous at bgcpartners dot com
2011-02-03 21:27 ` [Bug c++/47603] " pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).