http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58564

--- Comment #3 from John Regehr <regehr at cs dot utah.edu> ---
Kai, this is a real bug, please reopen it.

Here is what I get out of -fdump-tree-original:

  b = (int) (d == &c && a != 1);

This is wrong.

One way to illustrate the problem is to remove the useless comma operator from
the test case, which now looks like this (I've also added parens around the ^):

int printf(const char *, ...);
int a, b;
short *c;
short **d = &c;
int main() {
  b = (0 > ((&c == d) & (1 && (a ^ 1)))) | 0U;
  printf("%d\n", b);
  return 0;
}

Now -fdump-tree-original does a better job:

 b = (int) (d == &c && a != 1) < 0;

And now all compilers agree on the output:

[regehr@imp r102]$ gcc-4.4 small2.c ; ./a.out 
0
[regehr@imp r102]$ gcc-4.5 small2.c ; ./a.out 
0
[regehr@imp r102]$ gcc-4.6 small2.c ; ./a.out 
0
[regehr@imp r102]$ gcc small2.c ; ./a.out 
0
[regehr@imp r102]$ clang small2.c ; ./a.out 
0

Reply via email to