Bug 36521 - Expression in for expression gets wrong value
Summary: Expression in for expression gets wrong value
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.4.4
: P3 normal
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-13 08:51 UTC by Peter Hedinger
Modified: 2008-06-13 11:28 UTC (History)
1 user (show)

See Also:
Host: CYGWIN_NT-5.1 duane 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygw
Target:
Build: gcc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
Known to work: 3.3.6 4.1.0
Known to fail: 3.4.6 4.0.4
Last reconfirmed:


Attachments
test.i (3.99 KB, text/plain)
2008-06-13 08:52 UTC, Peter Hedinger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Hedinger 2008-06-13 08:51:20 UTC
The program below on gcc 4.1.2 prints:

> gcc4 test.c
> ./a.out
got 0
x
y
done

----------------------------------
The program below on gcc 3.4.4 prints:

> gcc test.c
> ./a.out
got 0
x
y

and then locks up...

----------------------------------

#include <stdio.h>

int main()
{
  unsigned int var102 = 1;
  int a = ( var102 >> 0x1eU & sizeof 290 );
  printf("got %d\n", a); fflush(stdout);

  for ( ; 0; )
  {}
  printf("x\n"); fflush(stdout);
  
  for ( ; a; )
  {}
  printf("y\n"); fflush(stdout);
  
  for ( ; ( var102 >> 0x1eU & sizeof 290 ); ) // Fails here
  {}
  printf("done\n");
  
  return 0;
}
Comment 1 Peter Hedinger 2008-06-13 08:52:16 UTC
Created attachment 15760 [details]
test.i
Comment 2 Richard Biener 2008-06-13 11:28:36 UTC
Fixed in 4.1.0