Another silly question
Pete Holsberg
pjh at mccc.UUCP
Tue May 23 07:36:24 AEST 1989
In article <17657 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
=>>In article <749 at mccc.UUCP> pjh at mccc.UUCP (Pete Holsberg) asked
=>>>why compilers produce different code for "a[i]" and "*(a+i)"?
=
=>In article <17635 at mimsy.UUCP> I noted that
=>>I have never observed one to do so. There is no reason for a compiler
=>>to generate different code, as the expressions are semantically identical.
=
=I have none of these machines, and only gcc as a compiler. The code
=produce by
=
= GNU C version 1.35 (vax) compiled by GNU C version 1.35.
=
=for both loops in
=
= int a[20];
= main(){int i;
= for(i=0;i<20;i++)a[i]=0;
= f();
= for(i=0;i<20;i++)*(a+i)=0;
= f();
= }
=
=was identical.
=Differing code sequences is one of two obvious possibilities, the other
=being differing multi-user loads. The latter seems less likely, especially
=if the results are repeatable. Why not compile to assembly and compare?
Thanks, Chris. I will try that on the 386 machine, as that assembly language
is not as much an unknown as those for the 680x0 and the WE320x0!
--
Pete Holsberg, Mercer County Community College, Trenton, NJ 08690
{backbone}!rutgers!njin!princeton!njsmu!mccc!pjh
More information about the Comp.lang.c
mailing list