This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Problems with g++ -O2 (v. 3.1, a bug?)
- From: Lee <birger dot b at gmx dot remove dot this dot net>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 02 Jun 2002 10:23:13 +0200
- Subject: Problems with g++ -O2 (v. 3.1, a bug?)
Hello there,
this tiny program test.c produces different output compiled with
gcc 3.1 on my athlon-linux-2.4.10
// Program start
#include <stdio.h>
struct S {
int i1;
int i2;
};
inline struct S Sdiff( struct S start, struct S stop ) {
struct S myS = { stop.i1 - start.i1, stop.i2 - start.i2 };
return myS;
}
int main()
{
struct S a = {1,1};
struct S b = {2,2};
struct S c = Sdiff(a,b);
printf( "c: %d %d\n",c.i1, c.i2);
}
// Program end
compiled with
g++ -O2 test.c -o test
-> "c: 134518664 0"
and
g++ -O0 test.c -o test
-> "c: 1 1" (as it supposed to be)
compiled with cc the output is correct in either
case, with or without optimization.
Can anyone reproduce this problem, is this a bug?
Birger