delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/05/18:15:29

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: printf bug ???
Date: Fri, 5 Jun 1998 21:21:39 +0100
Organization: None
Message-ID: <MYoEcGATNFe1Ewts@talula.demon.co.uk>
References: <Pine DOT GSO DOT 3 DOT 96 DOT 980605144528 DOT 10548A-100000 AT bert DOT eecs DOT uic DOT edu>
<35784F8A DOT AB5D79CC AT gpu DOT srv DOT ualberta DOT ca>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
Lines: 23
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Blaine Hodge writes:
>> >     printf("%d %d %d", i, i++, i++);
>
>Yup.  This is the correct response you should get.  Arguements are
>popped onto the stack right to left for function calls.
[...]
>Then its VC at fault (gee, imagine that), sounds like its evaluating it
>using the Pascal calling method, left to right, and not C/C++, right to
>left.

Not true. I'm not 100% sure of the rules for argument evaluation, but I
suspect that different compilers are allowed to do these in whatever
order they prefer. I do know for a fact that the ANSI standard explcitly
says that the results are undefined if you use a ++ operator in a
statement that also modifies the variable in some other way. Eg. if you
were to write something like "i += i++;", the compiler is entitled to do
whatever the hell it likes with that statement, including nothing. The
error lies in the code, not the compiler...


--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
"Miracles are nothing if you've got the wrong intentions" - Mike Keneally

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019