* [Bug c++/86465] [8/9/10/11 Regression] C++17 <optional> triggers: ‘<anonymous>’ may be used uninitialized in this function
[not found] <bug-86465-4@http.gcc.gnu.org/bugzilla/>
@ 2020-10-27 14:45 ` redi at gcc dot gnu.org
2020-11-16 21:09 ` redi at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2020-10-27 14:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86465
--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Created attachment 49449
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49449&action=edit
preprocessed source, unreduced, gzipped
Here's another example that produces this kind of warning, this time from the
libstdc++ sources (when built with -Wsystem-headers -Werror)
It seems to be complaining about the std::allocator<char> object, which is an
empty class so (1) who cares if it's uninitialized and (2) it's not
uninitialized.
$ ~/gcc/11/bin/g++ -O2 -Wall cow-fs_path.ii -c
In file included from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/string:55,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/stdexcept:38,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/system_error:40,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/fs_fwd.h:35,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/filesystem:43,
from
/home/jwakely/src/gcc/libstdc++-v3/src/c++17/fs_path.cc:34,
from
/home/jwakely/src/gcc/libstdc++-v3/src/c++17/cow-fs_path.cc:26:
In static member function ‘static _CharT* std::basic_string<_CharT, _Traits,
_Alloc>::_S_construct(_InIterator, _InIterator, const _Alloc&,
std::forward_iterator_tag) [with _FwdIterator = const char*; _CharT = char;
_Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’,
inlined from ‘static _CharT* std::basic_string<_CharT, _Traits,
_Alloc>::_S_construct(_InIterator, _InIterator, const _Alloc&,
std::forward_iterator_tag) [with _FwdIterator = const char*; _CharT = char;
_Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:589:7,
inlined from ‘static _CharT* std::basic_string<_CharT, _Traits,
_Alloc>::_S_construct(_InIterator, _InIterator, const _Alloc&) [with
_InIterator = const char*; _CharT = char; _Traits = std::char_traits<char>;
_Alloc = std::allocator<char>]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:5151:30,
inlined from ‘std::basic_string<_CharT, _Traits,
_Alloc>::basic_string(const _CharT*, std::basic_string<_CharT, _Traits,
_Alloc>::size_type, const _Alloc&) [with _CharT = char; _Traits =
std::char_traits<char>; _Alloc = std::allocator<char>]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:3620:9,
inlined from ‘std::basic_string<_CharT, _Traits,
_Alloc>::basic_string(std::basic_string<_CharT, _Traits, _Alloc>::__sv_wrapper,
const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:3541:65,
inlined from ‘std::basic_string<_CharT, _Traits,
_Alloc>::basic_string(const _Tp&, const _Alloc&) [with _Tp =
std::basic_string_view<char>; <template-parameter-2-2> = void; _CharT = char;
_Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:3731:58,
inlined from ‘std::filesystem::path::path(const _Source&,
std::filesystem::path::format) [with _Source = std::basic_string_view<char>;
_Require = std::filesystem::path]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/fs_path.h:304:9,
inlined from ‘void
std::filesystem::path::_M_concat(std::basic_string_view<char>)’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/fs_path.h:340:24:
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:604:36:
warning: ‘<anonymous>’ may be used uninitialized [-Wmaybe-uninitialized]
604 | _Rep* __r = _Rep::_S_create(__dnew, size_type(0), __a);
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/string:55,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/stdexcept:38,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/system_error:40,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/fs_fwd.h:35,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/filesystem:43,
from
/home/jwakely/src/gcc/libstdc++-v3/src/c++17/fs_path.cc:34,
from
/home/jwakely/src/gcc/libstdc++-v3/src/c++17/cow-fs_path.cc:26:
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:
In member function ‘void
std::filesystem::path::_M_concat(std::basic_string_view<char>)’:
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:980:5:
note: by argument 3 of type ‘const std::allocator<char>&’ to ‘static
std::basic_string<_CharT, _Traits, _Alloc>::_Rep* std::basic_string<_CharT,
_Traits, _Alloc>::_Rep::_S_create(std::basic_string<_CharT, _Traits,
_Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type,
const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>]’ declared here
980 | basic_string<_CharT, _Traits, _Alloc>::_Rep::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/filesystem:44,
from
/home/jwakely/src/gcc/libstdc++-v3/src/c++17/fs_path.cc:34,
from
/home/jwakely/src/gcc/libstdc++-v3/src/c++17/cow-fs_path.cc:26:
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/fs_path.h:304:9:
note: ‘<anonymous>’ declared here
304 | : _M_pathname(_S_convert(__detail::__effective_range(__source)))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/string:55,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/stdexcept:38,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/system_error:40,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/fs_fwd.h:35,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/filesystem:43,
from
/home/jwakely/src/gcc/libstdc++-v3/src/c++17/fs_path.cc:34,
from
/home/jwakely/src/gcc/libstdc++-v3/src/c++17/cow-fs_path.cc:26:
In static member function ‘static _CharT* std::basic_string<_CharT, _Traits,
_Alloc>::_S_construct(_InIterator, _InIterator, const _Alloc&,
std::forward_iterator_tag) [with _FwdIterator = const char*; _CharT = char;
_Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’,
inlined from ‘static _CharT* std::basic_string<_CharT, _Traits,
_Alloc>::_S_construct(_InIterator, _InIterator, const _Alloc&,
std::forward_iterator_tag) [with _FwdIterator = const char*; _CharT = char;
_Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:589:7,
inlined from ‘static _CharT* std::basic_string<_CharT, _Traits,
_Alloc>::_S_construct(_InIterator, _InIterator, const _Alloc&) [with
_InIterator = const char*; _CharT = char; _Traits = std::char_traits<char>;
_Alloc = std::allocator<char>]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:5151:30,
inlined from ‘std::basic_string<_CharT, _Traits,
_Alloc>::basic_string(const _CharT*, std::basic_string<_CharT, _Traits,
_Alloc>::size_type, const _Alloc&) [with _CharT = char; _Traits =
std::char_traits<char>; _Alloc = std::allocator<char>]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:3620:9,
inlined from ‘std::basic_string<_CharT, _Traits,
_Alloc>::basic_string(std::basic_string<_CharT, _Traits, _Alloc>::__sv_wrapper,
const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:3541:65,
inlined from ‘std::basic_string<_CharT, _Traits,
_Alloc>::basic_string(const _Tp&, const _Alloc&) [with _Tp =
std::basic_string_view<char>; <template-parameter-2-2> = void; _CharT = char;
_Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:3731:58,
inlined from ‘std::filesystem::path::path(const _Source&,
std::filesystem::path::format) [with _Source = char [2]; _Require =
std::filesystem::path]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/fs_path.h:304:9,
inlined from ‘std::filesystem::__detail::_Path<_Source>&
std::filesystem::path::operator=(const _Source&) [with _Source = char [2]]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/fs_path.h:340:24:
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:604:36:
warning: ‘<anonymous>’ may be used uninitialized [-Wmaybe-uninitialized]
604 | _Rep* __r = _Rep::_S_create(__dnew, size_type(0), __a);
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/string:55,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/stdexcept:38,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/system_error:40,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/fs_fwd.h:35,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/filesystem:43,
from
/home/jwakely/src/gcc/libstdc++-v3/src/c++17/fs_path.cc:34,
from
/home/jwakely/src/gcc/libstdc++-v3/src/c++17/cow-fs_path.cc:26:
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:
In function ‘std::filesystem::__detail::_Path<_Source>&
std::filesystem::path::operator=(const _Source&) [with _Source = char [2]]’:
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:980:5:
note: by argument 3 of type ‘const std::allocator<char>&’ to ‘static
std::basic_string<_CharT, _Traits, _Alloc>::_Rep* std::basic_string<_CharT,
_Traits, _Alloc>::_Rep::_S_create(std::basic_string<_CharT, _Traits,
_Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type,
const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>]’ declared here
980 | basic_string<_CharT, _Traits, _Alloc>::_Rep::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/filesystem:44,
from
/home/jwakely/src/gcc/libstdc++-v3/src/c++17/fs_path.cc:34,
from
/home/jwakely/src/gcc/libstdc++-v3/src/c++17/cow-fs_path.cc:26:
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/fs_path.h:304:9:
note: ‘<anonymous>’ declared here
304 | : _M_pathname(_S_convert(__detail::__effective_range(__source)))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/string:55,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/stdexcept:38,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/system_error:40,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/fs_fwd.h:35,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/filesystem:43,
from
/home/jwakely/src/gcc/libstdc++-v3/src/c++17/fs_path.cc:34,
from
/home/jwakely/src/gcc/libstdc++-v3/src/c++17/cow-fs_path.cc:26:
In static member function ‘static _CharT* std::basic_string<_CharT, _Traits,
_Alloc>::_S_construct(_InIterator, _InIterator, const _Alloc&,
std::forward_iterator_tag) [with _FwdIterator = const char*; _CharT = char;
_Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’,
inlined from ‘static _CharT* std::basic_string<_CharT, _Traits,
_Alloc>::_S_construct(_InIterator, _InIterator, const _Alloc&,
std::forward_iterator_tag) [with _FwdIterator = const char*; _CharT = char;
_Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:589:7,
inlined from ‘static _CharT* std::basic_string<_CharT, _Traits,
_Alloc>::_S_construct(_InIterator, _InIterator, const _Alloc&) [with
_InIterator = const char*; _CharT = char; _Traits = std::char_traits<char>;
_Alloc = std::allocator<char>]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:5151:30,
inlined from ‘std::basic_string<_CharT, _Traits,
_Alloc>::basic_string(const _CharT*, std::basic_string<_CharT, _Traits,
_Alloc>::size_type, const _Alloc&) [with _CharT = char; _Traits =
std::char_traits<char>; _Alloc = std::allocator<char>]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:3620:9,
inlined from ‘std::basic_string<_CharT, _Traits,
_Alloc>::basic_string(std::basic_string<_CharT, _Traits, _Alloc>::__sv_wrapper,
const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:3541:65,
inlined from ‘std::basic_string<_CharT, _Traits,
_Alloc>::basic_string(const _Tp&, const _Alloc&) [with _Tp =
std::basic_string_view<char>; <template-parameter-2-2> = void; _CharT = char;
_Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:3731:58,
inlined from ‘std::filesystem::path::path(const _Source&,
std::filesystem::path::format) [with _Source = std::basic_string_view<char>;
_Require = std::filesystem::path]’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/fs_path.h:304:9,
inlined from ‘void
std::filesystem::path::_M_append(std::basic_string_view<char>)’ at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/fs_path.h:340:24:
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:604:36:
warning: ‘<anonymous>’ may be used uninitialized [-Wmaybe-uninitialized]
604 | _Rep* __r = _Rep::_S_create(__dnew, size_type(0), __a);
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/string:55,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/stdexcept:38,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/system_error:40,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/fs_fwd.h:35,
from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/filesystem:43,
from
/home/jwakely/src/gcc/libstdc++-v3/src/c++17/fs_path.cc:34,
from
/home/jwakely/src/gcc/libstdc++-v3/src/c++17/cow-fs_path.cc:26:
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:
In member function ‘void
std::filesystem::path::_M_append(std::basic_string_view<char>)’:
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:980:5:
note: by argument 3 of type ‘const std::allocator<char>&’ to ‘static
std::basic_string<_CharT, _Traits, _Alloc>::_Rep* std::basic_string<_CharT,
_Traits, _Alloc>::_Rep::_S_create(std::basic_string<_CharT, _Traits,
_Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type,
const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>]’ declared here
980 | basic_string<_CharT, _Traits, _Alloc>::_Rep::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/filesystem:44,
from
/home/jwakely/src/gcc/libstdc++-v3/src/c++17/fs_path.cc:34,
from
/home/jwakely/src/gcc/libstdc++-v3/src/c++17/cow-fs_path.cc:26:
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/fs_path.h:304:9:
note: ‘<anonymous>’ declared here
304 | : _M_pathname(_S_convert(__detail::__effective_range(__source)))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^ permalink raw reply [flat|nested] 12+ messages in thread