[Bug tree-optimization/90905] missing -Wreturn-local-addr returning a local std::string::c_str()
glisse at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jun 18 17:45:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90905
--- Comment #7 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #6)
> With str being a local (non-reference) variable this should be diagnosed
> because of the str.D.28972._M_local_buf(12):
>
> # _47 = PHI <_59(9), &str.D.28972._M_local_buf(12), _59(8)>
> str ={v} {CLOBBER};
> return _47;
the dump above was obtained from your testcase, compiled with a slightly hacked
libstdc++
+++ basic_string.h 2019-06-18 17:40:06.435533019 +0200
@@ -214,7 +214,9 @@
_M_set_length(size_type __n)
{
_M_length(__n);
+ auto X = _M_data();
traits_type::assign(_M_data()[__n], _CharT());
+ if(X!=_M_data())__builtin_unreachable();
}
bool
+++ basic_string.tcc 2019-06-18 17:38:00.755534757 +0200
@@ -221,8 +221,12 @@
}
// Check for out_of_range and length_error exceptions.
+ auto X = _M_data();
__try
- { this->_S_copy_chars(_M_data(), __beg, __end); }
+ {
+ this->_S_copy_chars(_M_data(), __beg, __end);
+ if(X!=_M_data())__builtin_unreachable();
+ }
__catch(...)
{
_M_dispose();
and I am really not seeing a warning. But that's probably because the
path-isolation pass is too early (from a warning PoV), the IL doesn't look that
nice at that time yet.
More information about the Gcc-bugs
mailing list