configured with: /usr/local/src/add-on/gcc-3.0.2/configure --prefix=/usr/add-on/gcc-3.0.2 Description: The values of the two occurrences of (tmpvar->num = tmpnum) are not computed correctly; I think the compiler loses track of which registers contain each value. I also see the same error in the IBM S390 version of the compiler. The test program should exit with status = 0 if the compilation is valid, status = 1 if invalid. The Sun WorkShop Compiler 5.0 compiles this code correctly. How-To-Repeat: gcc -o gccerr gccerr.c; ./gccerr; echo $? Fix: Simplify expression --==_Exmh_-1288580240 Content-Type: text/plain ; name="gccerr.c"; charset=us-ascii Content-Description: gccerr.c Content-Disposition: attachment; filename="gccerr.c" typedef struct { char *str; /* the actual str */ int len; /* len of malloc'ed space */ int refcnt; /* number of times this string in use */ } STR, *STRP; typedef struct { STRP string; double num; /* num if pss and used */ char cur; /* indication of current type */ } VAR, *VARP; extern double atof(); extern int strlen(); extern void exit(); STR s_temp = { "asdf", 5, 1 }; VAR s_Au_temp = { &s_temp, 0.0, 1 }; STR s_zero = { "0.0", 4, 3 }; VAR s_Au_subs = { &s_zero, 0.0, 1 }; VAR s_Au_send = { &s_zero, 0.0, 1 }; VAR s_Au_slen = { &s_zero, 0.0, 1 }; VARP tmpvar; double tmpnum; VARP Au_temp = &s_Au_temp; VARP Au_subs = &s_Au_subs; VARP Au_send = &s_Au_send; VARP Au_slen = &s_Au_slen; main() { if ( ( ( Au_subs->cur & (1<<1) ) || ( Au_subs->cur |= (1<<1) , Au_subs->num = atof(( Au_subs->string->str ) ) ) ) , ( ( ( (tmpnum = ( (Au_subs->num + 255) )) , (tmpvar = ( Au_send )) , (tmpvar->cur = ((1<<1) | (1<<2) | (1<<3) ) ) ) , (tmpvar->num = tmpnum) ) > ( ( (tmpnum = ( ((double)strlen(( Au_temp->string->str ))) )) , (tmpvar = ( Au_slen )) , (tmpvar->cur = ((1<<1) | (1<<2) | (1<<3)) ) ) , (tmpvar->num = tmpnum)) ) ) { exit(0); /* correct */ } else { exit(1); /* invalid */ } } Release: unknown
State-Changed-From-To: open->analyzed State-Changed-Why: There is no sequence point in C after first operand of < operator, so your testcase has undefined behaviour. See ISO C99 Annex C, for example. There are sequence points after first operand of comma and at the end of if controlling expression, but there is nothing which requires < operands to be evaluated in any specific order.
State-Changed-From-To: analyzed->closed State-Changed-Why: Not a bug, as diagnosed by Jakub.
Reopening to mark as a duplicate of...
...PR 11751. *** This bug has been marked as a duplicate of 11751 ***