&&**
Sudheer Apte
sa1z+ at andrew.cmu.edu
Tue Sep 11 07:34:46 AEST 1990
throopw at sheol.UUCP (Wayne Throop) writes:
> > From: ridoux at irisa.fr (Olivier Ridoux)
> > "what is the rational of the cc and gcc compilers (sun4) that
> > makes them accept the following program...
> ...
> Now, on the other hand, I ran this program through microsoft C,
> feeling confident that it would be flagged as erronious. To my
> surprise and amazement, it ran just as Olivier describes. No
> slips, no drips, (and worst) no errors.
>
> This is apparently a VERY common bug. It shakes my faith in
> the competence of C implementors. Unless I'm missing something
> quite major...???
You are quite correct. GNU's gcc compiles it without a peep!
What is going on? The standard seems quite clear about this, but
I've never known gcc to misbehave before...
Sudheer.
------------------
The program:
main()
{
char c = 'c' ;
char * pc = &c ;
char ** ppc = &pc ;
char d = 'd' ;
char * pd = &d ;
char ** ppd = &pd ;
printf( "%c\n", *(*( &(&(*(*(ppc)))) )) ); /* 1 */
printf( "%c\n", *(*( &(&(*(*(ppd)))) )) ); /* 2 */
&(&(*(*(ppc)))) = ppd ;
printf( "%c\n", *(*( &(&(*(*(ppc)))) )) ); /* 3 */
}
...{harvard, uunet}!andrew.cmu.edu!sa1z
sa1z%andrew at CMCCVB.BITNET
More information about the Comp.lang.c
mailing list