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: Temporaries


I need to correct a typo in my original message.

> > I'm attempting to port some code that has the following definitions:
> > --------------------- cut here ---------------
> > class Set {
> > 	public:
> > 	Set &operator |= ( Set & );
> > 	Set &operator | ( Set & );
> > };
> > Set &Set::operator | ( Set &rhs ) {
> > 	return Set(rhs)|=lhs;
> > };
> > --------------------- cut here ---------------
> 
> This is not legal C++.
> 
> > Under visual c++, this is fine,
> 
> Actually it may not be fine under C++ ("compiles" != "fine").  That is,

I meant to write "under Visual C++" ^ here.

> the code in question is likely to have strange bugs, as you are trying to
> create a reference to a temporary which is on a portion of the stack that
> is popped.

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