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

--- Comment #1 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
If instead I use `std::string_view` in `-O3` (`-O0` works),
it also diagnoses (<https://cpp2.godbolt.org/z/h7zooM35G>):

```
In file included from /app/module.cpp:2,
of module hello, imported at /app/main.cpp:2:
In member function 'constexpr const std::basic_string_view<_CharT,
_Traits>::value_type* std::basic_string_view<_CharT, _Traits>::data() const
[with _CharT = char; _Traits = std::char_traits<char>]',
    inlined from 'std::basic_ostream<_CharT, _Traits>&
std::operator<<(basic_ostream<_CharT, _Traits>&, basic_string_view<_CharT,
_Traits>) [with _CharT = char; _Traits = char_traits<char>]' at
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/string_view:762:30,
    inlined from 'int main()' at /app/main.cpp:3:46:
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/string_view:292:22:
warning: 'this' is used uninitialized [-Wuninitialized]
  292 |       { return this->_M_str; }
      |                      ^~~~~~
In file included from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/bits/basic_string.h:47,
                 from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/string:54,
                 from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/bits/locale_classes.h:40,
                 from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/bits/ios_base.h:41,
                 from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/ios:44,
                 from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/ostream:40,
                 from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/iostream:41,
                 from /app/main.cpp:1:
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/string_view: In
function 'int main()':
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/string_view:760:5:
note: 'this' was declared here
  760 |     operator<<(basic_ostream<_CharT, _Traits>& __os,
      |     ^~~~~~~~
```

Reply via email to