This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: The order of calling functions and << <<


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]