delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/20/21:07:05

Sender: nate AT cartsys DOT com
Message-ID: <365617BE.29F66A0A@cartsys.com>
Date: Fri, 20 Nov 1998 17:30:38 -0800
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.05 [en] (X11; I; Linux 2.0.35 i486)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
CC: eliz AT is DOT elta DOT co DOT il
Subject: Re: pascal & cdecl again
References: <LLIHMJDBEPMOBAAA AT theglobe DOT com>
Reply-To: djgpp AT delorie DOT com

Gabriel Maffla wrote:
>  g(f1(),f2());

> If func g is "stdcall", the program output must be:
> (f1)
> (f2)
> 
> But it is not so. What's wrong??

You.  :)  The C standard says that function arguments can be evaluated
in any order.  This is independent of the order in which they are
pushed.  So GCC would be well within its rights to do:

call f2
movl %eax, %ebx
call f1
pushl %ebx
pushl %eax
call g

or something similar, if it thought it was more efficient.

If you want to force arguments to be evaluated in a certain order, you
must use temporary variables.
-- 

Nate Eldredge
nate AT cartsys DOT com

- Raw text -


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