[Bug c++/115987] False "possibly dangling reference" false positive when having an extra template parameter
durosu at yahoo dot com
gcc-bugzilla@gcc.gnu.org
Thu Jul 18 18:01:27 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115987
--- Comment #17 from Dan Urosu <durosu at yahoo dot com> ---
I just tried something after you explained how this warning works.
The most common cause of a real dangling ref is not caught unfortunately.
If you replace the unwrap_1 impl with the below you get no warning.
template <typename T>
const T& unwrap_1(const Wrapper<T>& r) {
Wrapper<T> r1(r);
return r1.value(); // real dangling ref here!
}
More information about the Gcc-bugs
mailing list