https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63181
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
N.B. that's not a temporary, it's a named lvalue, but we should definitely
diagnose it.
Since 4.7 GCC does now diagnose similar cases with temporaries resulting from
implicit conversions:
struct Foo {
Foo(short x): x_(x) { }
const int& x_;
};
int main()
{
Foo f(0);
return f.x_;
}
t.cc: In constructor ‘Foo::Foo(short int)’:
t.cc:2:22: warning: a temporary bound to ‘Foo::x_’ only persists until the
constructor exits [-Wextra]
Foo(short x): x_(x) { }
^