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: Nyan Htoo Tin
Subject: Re: [Tinycc-devel] semantic of postincrement
Date: Fri, 9 Oct 2009 21:36:37 +0800

Dear Torsten Finke,

Please take a look at http://c-faq.com/expr/evalorder1.html.

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
>




reply via email to

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