This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
An alias bug?
- To: egcs-bugs at cygnus dot com
- Subject: An alias bug?
- From: hjl at lucon dot org (H.J. Lu)
- Date: Sun, 28 Jun 1998 10:26:55 -0700 (PDT)
I got this with egcs-2.91.42 19980627:
# gcc foo.c
# a.out
# gcc -O foo.c
# a.out
zsh: 3823 abort ./a.out
Is this an alias bug or the code is buggy?
Thanks.
--
H.J. Lu (hjl@gnu.org)
---foo.c--
static long
Add (long *C, long *A, long *B, unsigned int N)
{
long carry = 0;
unsigned int i;
for (i = 0; i < N; i+=2)
{
long long u = (long long) carry + A [i] + B [i];
C [i] = (long) u;
#if 1
u = (long long) (*(((long *)&( u ))+1)) + A [i+1] + B [i+1];
#else
carry = (*(((long *)&(u))+1));
u = (long long) carry + A [i+1] + B [i+1];
#endif
C [i+1] = (long) u;
carry = (*(((long *)&(u))+1));
}
return carry;
}
main ()
{
long A [2] = {0};
long B [2] = {2, 0};
Add (A, A, B, 2);
if (A [0] != 2 || A [1] != 0)
abort ();
return 0;
}