Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!njin!princeton!njsmu!mccc!pjh From: pjh@mccc.UUCP (Pete Holsberg) Newsgroups: comp.lang.c Subject: Re: Another silly question Message-ID: <759@mccc.UUCP> Date: 22 May 89 21:36:24 GMT References: <17812@cup.portal.com> <607@kl-cs.UUCP> <749@mccc.UUCP> <756@mccc.UUCP> <17657@mimsy.UUCP> Reply-To: pjh@mccc.UUCP (Pete Holsberg) Organization: The College On The Other Side of U. S. Route 1 Lines: 34 In article <17657@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: =>>In article <749@mccc.UUCP> pjh@mccc.UUCP (Pete Holsberg) asked =>>>why compilers produce different code for "a[i]" and "*(a+i)"? = =>In article <17635@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