This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: The order of calling functions and << <<
- To: Joe Buck <jbuck at Synopsys dot COM>
- Subject: Re: The order of calling functions and << <<
- From: Alex Buell <alex dot buell at tahallah dot demon dot co dot uk>
- Date: Mon, 7 Dec 1998 13:03:10 -0500 (EST)
- cc: Carlo Wood <carlo at runaway dot xs4all dot nl>, egcs at cygnus dot com
On Mon, 7 Dec 1998, Joe Buck wrote:
> the compiler is free to either do operator<<(cout,"1") first or to call
> foo() first. This means that you could get "124\n" or "214\n".
YEP! Actually, what happens is you get 2134 with egcs-1.1b.
This I believe happens because foo() is called first, which gives you 2,
and returns the result (3) to the main program. Then the cout stuff is
parsed .. giving 134.
I think this part needs clarifying in the ISO C++ standards. This is one
heck of a nasty pitfall!
Cheers,
Alex.
---
/\_/\ Legalise cannabis now!
( o.o ) Grow some cannabis today!
> ^ < Peace, Love, Unity and Respect to all.
Check out http://www.tahallah.demon.co.uk
Linux lo-pc3035a 2.1.130 #10 Mon Nov 30 10:49:50 EST 1998
One Intel Pentium 166MHz processor, 66.36 total bogomips, 16M RAM
System library 5.4.44