https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109671

--- Comment #2 from Patrick J. LoPresti <lopresti at gmail dot com> ---
Um... OK...

So I have to "correct" my code like so:

const Foo &bug(bool x)
{
  const std::string s = (x ? "x" : "y");
  const Foo &f = get_foo_by_name(s);
  return f;
}

But if get_foo_by_name() has the problem GCC is worried about, this does not
even fix it.

This warning seems silly to me. "I cannot tell if you are managing lifetimes
properly, so I will just recommend you do not use temporaries"?

Const references have always bound to temporaries. This warning seems to be
discouraging that (?)

Reply via email to