Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!rutgers!rochester!pt.cs.cmu.edu!o.gp.cs.cmu.edu!andrew.cmu.edu!sa1z+ From: sa1z+@andrew.cmu.edu (Sudheer Apte) Newsgroups: comp.lang.c Subject: Re: &&** Message-ID: Date: 10 Sep 90 21:34:46 GMT References: <1990Sep7.021321.18381@watmath.waterloo.edu> <1990Sep7.080855.24070@irisa.fr>, <0926@sheol.UUCP> Organization: Civil Engineering, Carnegie Mellon, Pittsburgh, PA Lines: 43 In-Reply-To: <0926@sheol.UUCP> throopw@sheol.UUCP (Wayne Throop) writes: > > From: ridoux@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@CMCCVB.BITNET