Date: Sat, 17 May 2003 16:20:05 -0400 From: David Witbrodt Subject: References to temporary objects in C++ To: DJGPP mailing list Message-id: <3EC69975.55BE1034@alpha.delta.edu> Organization: Delta College MIME-version: 1.0 X-Mailer: Mozilla 4.79 [en] (Win98; U) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT X-Accept-Language: en Reply-To: djgpp AT delorie DOT com Hi folks, This is maybe a little bit frivolous... A year or two ago, I was frustrated with GCC not being able to accept a reference to a temporary object as a function argument, like this: class UserType { // ... // UserType operator+ (const UserType&); // ... }; void func (const UserType&); int main () { UserType a, b; func (a+b); // ... } I had learned C++ first in the early 1990s using Turbo C++, and I remember using examples from Stroustrup's book that did things like this without any trouble on that compiler. When this issue arose for me (a year or two ago) I found that the DJGPP compiler didn't like this sort of syntax, that it was a known problem, and that the advice being given on this list was to create one's own temporary (i.e., Usertype c=a+b;) as a workaround. I was tinkering around today, and tried again. I notice that it is OK now, no warnings or errors. Was this a DJGPP issue? Or simply a GCC issue? Does anyone know when it changed? (This is obviously an unimportant matter, but I am simply curious.) Dave W.