https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109671
Marek Polacek changed:
What|Removed |Added
Resolution|--- |DUPLICATE
CC|
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109671
--- Comment #4 from CVS Commits ---
The releases/gcc-13 branch has been updated by Marek Polacek
:
https://gcc.gnu.org/g:6b927b1297e66e26e62e722bf15c921dcbbd25b9
commit r13-7276-g6b927b1297e66e26e62e722bf15c921dcbbd25b9
Author: Marek Polacek
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109671
--- Comment #3 from Patrick J. LoPresti ---
(In reply to Andrew Pinski from comment #1)
> There is no way for GCC to know that get_foo_by_name does not store the
> argument into what is returned so it warns about this case ...
To summarize:
GC
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109671
--- Comment #2 from Patrick J. LoPresti ---
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
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109671
--- Comment #1 from Andrew Pinski ---
There is no way for GCC to know that get_foo_by_name does not store the
argument into what is returned so it warns about this case ...