Mail Archives: djgpp/1997/05/09/14:24:44
Hi everybody:
Here SET again with bad news. I'm comunicating bugs of GCC to the list
because it can affect to somebody and I know how hard is to find a bug in
a program when the fault is in the compiler.
"Daniel W. Moore" <dwmoore AT clark DOT net> reported a bug to the FSF in the C++
front end. Looks like a bug but perhaps is something related to C++.
The following code outputs different results in C and C++. GCC just says
that (void *)aa isn't equal to (void*)&aa, but if we ask for the value of
each expression it return the same number.
So is that a bug or is something related to C++? From my point of view the
cast to (void *) must kill any difference and hence that's a bug.
#include <stdio.h>
int aa[3]={7,8,9};
main()
{
int i;
/* the following statements should print the same value twice */
printf("(void *)aa is %X and (void*)&aa is %X so they are %s equal!?!\n",
(void *)aa,(void*)&aa,((void*) aa != (void*) &aa) ? "not" : "");
i = (((void*) aa != (void*) &aa) ? 0 : sizeof(aa));
printf(" %d\n", i);
i = (((void*) aa == (void*) &aa) ? sizeof(aa) : 0);
printf(" %d\n", i);
return 0;
}
------------------------------------ 0 --------------------------------
Visit my home page: http://www.geocities.com/SiliconValley/Vista/6552/
Salvador Eduardo Tropea (SET). (Electronics Engineer)
Address: Curapaligue 2124, Caseros, 3 de Febrero
Buenos Aires, (1678), ARGENTINA
TE: +(541) 759 0013
- Raw text -