Opened 5 years ago
Last modified 5 years ago
#140 new defect
conditional expression bad code generation
Reported by: | pabuhr | Owned by: | |
---|---|---|---|
Priority: | critical | Component: | cfa-cc |
Version: | 1.0 | Keywords: | |
Cc: |
Description
int main() { char c[1] = { 3 }; int i = 4; int r = 3 < 4 ? c[0] : i; printf( "%d\n", r ); } $ a.out -460718077
The problem code is:
char _X1cA0c_2[((unsigned long int )1)] = { ((char )3) }; signed int _X1ii_2 = 4; signed int _X1ri_2 = (*(((3<4)!=((signed int )0)) ? ((signed int *)(&_X1cA0c_2[((signed long int )0)])) : (&_X1ii_2)));
and the cast is wrong for _X1cA0c_2. It should be (char *). I think the problem is unifying the type for the two expressions.
Note: See
TracTickets for help on using
tickets.
That looks like it's performing a conversion on the references char & -> int &, rather than converting char & -> char -> int. I'm not sure how best to verify that, but maybe that gives you a thread to pull on.