20187 – [3.4 Regression] wrong code for ((unsigned char)(unsigned long long)((a?a:1)&(a*b)))?0:1) (original) (raw)
Description heinrich.brand 2005-02-24 12:05:08 UTC
Function test has value 0. Should have value 1;
#include <stdio.h> int a=0x101; int b=0x100;
int test(){ return ( ((unsigned char)(unsigned long long) ( (a?a:1) & (a*b) )) ? 0 : 1 ); }
int main(void){ if((unsigned char)(unsigned long long) (a&(a*b)))return 2; if( test() ){ printf("successful\n"); return 0; } else { printf("failed\n"); return 1; } }
Related to Bug 19606?
GNU CPP version 2.95.2 19991024 (release) (sparc) successful GNU C version 3.3.3 (sparc-sun-solaris2.8) failed
GNU CPP version 3.2 (cpplib) (i386 Linux/ELF) failed GNU C version 3.3.2 (i686-pc-linux-gnu) failed GNU C version 3.3.5 (i686-pc-linux-gnu) failed GNU C version 3.4.3 (i686-pc-linux-gnu) failed
Comment 1 Drea Pinski 2005-07-01 19:39:19 UTC
Confirmed, only a regression on the 3.4 branch.
Comment 2 Richard Sandiford 2005-07-28 10:55:10 UTC
This is another symptom of the same bug as PR19283. I'm testing a backport of that patch.
Comment 6 Richard Sandiford 2005-07-28 16:35:47 UTC
Patch applied to 3.4 branch. Testcase also applied to 4.0 and mainline (where it already passes).