An alias bug

Jeffrey A Law law@cygnus.com
Sat Jul 11 22:47:00 GMT 1998


  In message < m0yv93A-000266C@ocean.lucon.org >you write:

  > Here is a C testcase from Richard. The binary aborts when compiled with
  > -O2. I have another 500 line C++ testcase which results in an infinite
  > loop when compiled with -O2. The problems with loop and alias are
I believe this testcase is bogus.

  > H.J.
  > -- 
  > H.J. Lu (hjl@gnu.org)
  > ----
  > long A [2] = {0};
  > long B [2] = {2, 0};
  > 
  > typedef union
  > {
  >   long long ll;
  >   long l[2];
  > } long_long_type;
  > 
  > main ()
  > {
  >   unsigned int i;
  >   long long u = -1;
  >   for (i = 0; i < 2; i+=2)
  >   {
  >     u = A [i] + B [i];
  >     u = ((long_long_type *) &u)->l [1] + A [i+1] + B [i+1];
"u" is a "long long", I don't think casting it to "long_long_type"
is valid C or C++.

jeff



More information about the Gcc-bugs mailing list