long foo( bool flag, int __x ) { return ( flag ? (unsigned)__x : __x ); // broken }
long bar( bool flag, int __x ) { if ( flag ) return (unsigned)__x; else return __x; } 0000000000000000 <foo(bool, int)>: 0: 89 f0 mov %esi,%eax 2: c3 retq 0000000000000010 <bar(bool, int)>: 10: 89 f0 mov %esi,%eax 12: 40 84 ff test %dil,%dil 15: 48 63 f6 movslq %esi,%rsi 18: 48 0f 44 c6 cmove %rsi,%rax 1c: c3 retq -- Summary: wrong-code / trivial logic misscompiled. Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pluto at agmk dot net GCC target triplet: x86_64-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29553