This is seen on svn 137045. [EMAIL PROTECTED] tmp27]$ current-gcc -O -fwrapv small.c -o small [EMAIL PROTECTED] tmp27]$ ./small 0 [EMAIL PROTECTED] tmp27]$ current-gcc -Os -fwrapv small.c -o small [EMAIL PROTECTED] tmp27]$ ./small 2
[EMAIL PROTECTED] gcc-current]$ current-gcc -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../configure --program-prefix=current- --enable-languages=c,c++ --prefix=/home/regehr Thread model: posix gcc version 4.4.0 20080623 (experimental) (GCC) #include <limits.h> #include <stdio.h> static inline int lshift_s_s(int left, int right) { if ((left < 0) || (right < 0) || (right >= sizeof(int)*CHAR_BIT) || (left > (INT_MAX >> right))) { /* Avoid undefined behavior. */ return left; } return left << right; } static inline unsigned int lshift_u_u(unsigned int left, unsigned int right) { if ((right >= sizeof(unsigned int)*CHAR_BIT) || (left > (UINT_MAX >> right))) { /* Avoid undefined behavior. */ return left; } return left << right; } static inline int rshift_s_u(int left, unsigned int right) { if ((left < 0) || (right >= sizeof(int)*CHAR_BIT)) { /* Avoid implementation-defined and undefined behavior. */ return left; } return left >> right; } int func_47(unsigned int p_48 ) ; int func_47(unsigned int p_48 ) { int tmp = lshift_u_u(p_48, p_48); int tmp___0 = lshift_s_s(tmp, 1); int tmp___1 = rshift_s_u(1 + p_48, tmp___0); return (tmp___1); } int main(void) { int x = func_47(1); printf("%d\n", x); return 0; } -- Summary: likely codegen bug Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: regehr at cs dot utah dot edu GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36613