------- Comment #3 from pinskia at gcc dot gnu dot org 2006-02-25 20:35 ------- (In reply to comment #2) > I seems trivial for gcc to find this sort of error: Just watch out for > const reference members in classes, and then see whether they are bound > to a temporary (gcc warns about this in other cases, so it seems to know > about temporaries) --- this seems easy to observe and seems never to > be of any use. Lets look at how GCC (or anyother compiler) looks at this issue: Y(const X& x1) : x(x1) {} How would GCC or anyother compiler know that x1 points to a temporary variable?
Y y((X())); How does GCC know that the temporary that holds X() is going to be stored in y? > > I don't understand "IPA". inter-procedure analysis. > And finally, sure, books speak about lifetime of temporaries, but references > are badly covered. And then this special behaviour of binding to temporaries, > different for class members and block members, I carefully searched for it in > the 30 something C++ books I have, but didn't find anything. There is no special behavior really. Maybe that is your misunderstanding. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26471