Article View: gnu.gcc.bug
Article #5917Re: Error in Compiling the following code
From: Victor Sune
Date: Wed, 29 Jan 1997 00:00
Date: Wed, 29 Jan 1997 00:00
63 lines
2496 bytes
2496 bytes
On Monday 27 N. Damodharan wrote:
>
> Hi,
>
> When I compile the following code in cc and gcc
>
> -----------------------------------------------
> main ()
> {
> static int a[] = {97,98,99,100,101,102,103,104};
> int *ptr = a ;
>
> printf("%d %d %d %d %d %d %d %d\n",*(++ptr), *(ptr--),*(ptr), *(ptr++), *(ptr++), *(ptr),*(++ptr),*(ptr));
>
> ptr = a ;
> print(++ptr, ptr--,ptr, ptr++, ptr++, ptr,++ptr,ptr);
> }
>
> print (a,b,c,d,e,f,g,h)
> int *a,*b,*c,*d,*e,*f,*g,*h;
> {
> printf("%d %d %d %d %d %d %d %d",*a, *b, *c,*d,*e,*f,*g,*h);
> }
>
> ------------------------------------------
>
> in GCC I get the following output...
> 98 98 97 97 98 99 100 100
> 98 98 100 97 98 99 100 100
>
> in cc I get the following output...
> 98 98 97 97 98 99 100 100
> 98 98 97 97 98 99 100 100
>
> Looking at the semantics of the program I feel that CC
> results are correct while that of GCC are wrong. I feel this
> has some thing to do with the way parameter passed to a
> function are parsed...
>
> Can you please lookinto this an send me reasons for the
> same..
>
> Also can you let me know how the function parameters are
> parsed in GCC..
>
> Regards,
> Dams.
> -----------------------------------------------------
> After the game both the King and the Pawn go into the same box.
> -----------------------------------------------------
What gcc version are you using?
With gcc-2.5.8 under SunOS 5.5 I get the following output:
98 98 97 97 98 99 100 100
98 98 100 97 98 100 100 100
When you say cc are you meaning Sun CC compiler? With Sun CC 4.0 under
the same operative system I get the following surprising results:
100 97 100 -268437948 97 100 100 100
100 97 100 -268437948 97 100 100 100
Victor Sunye (sunye@eel.upc.es)
Technical Details
Message-ID:
<32EF08DE.510E@eel.upc.es>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<199701271124.GAA09540@sashp108.sasi.ernet.in>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 113d02,e2bba56dc5659051 X-Google-Attributes: gid113d02,public From: sunye@eel.upc.es (Victor Sune) Subject: Re: Error in Compiling the following code Date: 1997/01/29 Message-ID: <32EF08DE.510E@eel.upc.es> X-Deja-AN: 212946037 sender: bug-gcc-request@prep.ai.mit.edu references: <199701271124.GAA09540@sashp108.sasi.ernet.in> content-type: text/plain; charset=us-ascii organization: UPC x-gateway: relay5.UU.NET from bug-gcc to gnu.gcc.bug; Wed, 29 Jan 1997 03:26:49 EST mime-version: 1.0 newsgroups: gnu.gcc.bug x-mailer: Mozilla 3.0 (X11; I; SunOS 5.5 sun4m)