[Top][All Lists]

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

Re: [DotGNU]Hello from pnetC

From: Erik Rozendaal
Subject: Re: [DotGNU]Hello from pnetC
Date: Tue, 13 Aug 2002 10:13:56 +0200
User-agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.0.0) Gecko/20020802

Rhys Weatherley wrote:

Gopal already found one oddity last night when he became
the first test victim: evaluation order is the reverse of
regular C compilers.

   int i=10;
   printf("%d %d %d",i++,i++,i++);

   gcc : 12 11 10
   cscc: 10 11 12

This is due to the way the CLR works.  It always evaluates
from left to right, instead of the usual C right to left.
I don't think that there is anything that we can do about
this, unfortunately.

Actually, this is undefined behavior in C. Modifying a variable multiple time between sequence points (usually between statements, but there are other sequence points) is not allowed. Also, in C the evaluation order of function call arguments is not defined either. So both gcc and cscc are "correct". Although a correct (but evil) compiler could also format your harddrive...

See section 3 of the C FAQ at for more about sequence points. It'll quickly make you want to program C# or Java again :)


reply via email to

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