--- Comment #1 from pinskia at gcc dot gnu dot org 2006-02-25 19:57 ---
First:
Y y(X());
that declares a function rather than a variable.
You want:
Y y((X()));
Second, this is called life time and there is no way for GCC to know that
constructure's argument is used only for
--- Comment #2 from o dot kullmann at swansea dot ac dot uk 2006-02-25
20:15 ---
Sure, those additional brackets I missed because I created this case
from scratch (and then forgot about it).
But the other points I don't see:
I seems trivial for gcc to find this sort of error: Just
--- 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
--- Comment #4 from o dot kullmann at swansea dot ac dot uk 2006-02-25
21:21 ---
Y y((X()));
How does GCC know that the temporary that holds X() is going to be stored in
y?
By the definition of Y, obviously. There seems to be a very special way of
how GCC is parsing the input,