public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/21642] New: wrong code with -O2
@ 2005-05-18 10:02 joerg dot richter at pdv-fs dot de
  2005-06-06 15:17 ` [Bug target/21642] " dje at gcc dot gnu dot org
  2005-06-06 15:20 ` [Bug target/21642] [3.4 Regression] " pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 5+ messages in thread
From: joerg dot richter at pdv-fs dot de @ 2005-05-18 10:02 UTC (permalink / raw)
  To: gcc-bugs

$ gcc -v 
Reading specs from /pdv/.tools/pkg/gcc/3.4.3/bin/../lib/gcc/powerpc-ibm-
aix5.2.0.0/3.4.3/specs
Configured with: ../gcc-3.4.3/configure --prefix=/tools/pkg/gcc/3.4.3 --with-
ld=/bin/ld --with-as=/bin/as --disable-threads --enable-languages=c,c++
Thread model: aix
gcc version 3.4.3

// foo.c //

#include <stdio.h>

inline void
reverse( char* beg, char* end )
{
  while( beg < --end )
  {
    char t = *end;
    *end = *beg;
    *beg++ = t;
  }
}

void doIt( int* val )
{
  reverse( (char*)val, (char*)val + sizeof( *val ) );
}

int main()
{
  int d = 0x12345678;
  printf( "%x\n", d );
  doIt( &d );
  printf( "%x\n", d );
  return 0;
}

////

$ gcc -o foo foo.c -O2
$ foo
12345678
78345612

$ gcc -o foo foo.c
$ foo
12345678
78563412

Works with GCC 3.3.3

-- 
           Summary: wrong code with -O2
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: joerg dot richter at pdv-fs dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: powerpc-ibm-aix5.2.0.0
  GCC host triplet: powerpc-ibm-aix5.2.0.0
GCC target triplet: powerpc-ibm-aix5.2.0.0


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


^ permalink raw reply	[flat|nested] 5+ messages in thread
[parent not found: <bug-21642-5469@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2006-02-28 10:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-18 10:02 [Bug target/21642] New: wrong code with -O2 joerg dot richter at pdv-fs dot de
2005-06-06 15:17 ` [Bug target/21642] " dje at gcc dot gnu dot org
2005-06-06 15:20 ` [Bug target/21642] [3.4 Regression] " pinskia at gcc dot gnu dot org
     [not found] <bug-21642-5469@http.gcc.gnu.org/bugzilla/>
2005-10-07  4:04 ` gdr at gcc dot gnu dot org
2006-02-28 11:29 ` gdr at gcc dot gnu dot 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).