tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] semantic of postincrement


From: Dr.-Ing. Torsten Finke
Subject: Re: [Tinycc-devel] semantic of postincrement
Date: Fri, 9 Oct 2009 16:12:47 +0200
User-agent: Mutt/1.5.16 (2007-06-09)

Dear Nyan Htoo Tin, 

On Fri, Oct 09, 2009 at 09:36:37PM +0800, Nyan Htoo Tin wrote:
> Dear Torsten Finke,
> 
> Please take a look at http://c-faq.com/expr/evalorder1.html.

thank you for that hint. 

I see, that according to the sequence point concept these statements suffer
from the same undefinedness:

  a[i] = i++;  /* this one discussed by K+R */

  a[i++] = i;  /* equivalent trap */ 

Best regards 

Torsten Finke



> On Fri, Oct 9, 2009 at 9:08 PM, Dr.-Ing. Torsten Finke
> <address@hidden> wrote:
> > Dear TCC-Developers,
> >
> > running some tests on tcc-0.9.25 I found an interesting behaviour concerning
> > postincrement.
> >
> > Please consider the following little program:
> >
> > #--------------------------------------------------
> > #include <stdio.h>
> > int main()
> > {
> >    int i = 0, a[] = { -1, -1 };
> >    a[i++] = i;
> >    printf("%d %d\n", a[0], a[1]);
> >    return 0;
> > }
> > #--------------------------------------------------
> >
> > running it I expected the output to be:
> >
> > 0 -1
> >
> > but indeed it is:
> >
> > 1 -1
> >
> > Trying to understand the ANSI-C Standard, the evaluation sequence of the
> > assignment statement should be:
> > 1. evaluate right side (since assignment is right associative) -> i = 0
> > 2. calculate indix to "a" -> 0
> > 3. assign 0 to a[0]
> > 4. increment i
> >
> > Am I wrong?
> >
> > BTW: GCC, VC++, cc(HP-UX) do as I had expected; TCC and LCC do not, but do 
> > the
> > same.
> >
> >
> > TCC seems to be very nice. Thanks for your great work.
> >
> >
> > Best regards
> >
> >
> > Torsten Finke
> >
> >
> >
> > --
> >
> > ------------------------------------------------------------------------
> >
> > Dr.-Ing. Torsten Finke                       Amtsgericht Essen HRB 11500
> > Ingenieurgemeinschaft IgH                    USt-Id.-Nr.: DE 174 626 722
> > Ges. für Ingenieurleistungen mbH             Geschäftsführung:
> > Heinz-Bäcker-Str. 34                         Dr.-Ing. S. Rotthäuser
> > D-45356 Essen                                Dr.-Ing. T. Finke
> > Tel.: +49 201 / 360-14-17                    Dr.-Ing. W. Hagemeister
> > Fax.: +49 201 / 360-14-14                    Tel.: +49 201 / 360-14-0
> > address@hidden                  http://www.igh-essen.com
> >
> > ------------------------------------------------------------------------
> >
> >
> > _______________________________________________
> > Tinycc-devel mailing list
> > address@hidden
> > http://lists.nongnu.org/mailman/listinfo/tinycc-devel
> >
> 
> 
> _______________________________________________
> Tinycc-devel mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/tinycc-devel

-- 

------------------------------------------------------------------------

Dr.-Ing. Torsten Finke                       Amtsgericht Essen HRB 11500
Ingenieurgemeinschaft IgH                    USt-Id.-Nr.: DE 174 626 722
Ges. für Ingenieurleistungen mbH             Geschäftsführung:
Heinz-Bäcker-Str. 34                         Dr.-Ing. S. Rotthäuser
D-45356 Essen                                Dr.-Ing. T. Finke
Tel.: +49 201 / 360-14-17                    Dr.-Ing. W. Hagemeister
Fax.: +49 201 / 360-14-14                    Tel.: +49 201 / 360-14-0
address@hidden                  http://www.igh-essen.com

------------------------------------------------------------------------




reply via email to

[Prev in Thread] Current Thread [Next in Thread]