[Bug c++/107138] [12/13 regression] std::variant triggers false-positive 'may be used uninitialized' warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107138 Marco Clemencic changed: What|Removed |Added CC||marco.clemencic at gmail dot com --- Comment #3 from Marco Clemencic --- Created attachment 53918 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53918&action=edit another example of false uninitialized warning
[Bug c++/107138] [12/13 regression] std::variant triggers false-positive 'may be used uninitialized' warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107138 --- Comment #4 from Marco Clemencic --- I have a similar problem with this chunk of code: ``` #include #include #include #include #include struct Wrapper { using Map = std::map; using Value = std::variant; Wrapper(Value v) : data{std::move(v)} {} Value data; }; auto f() { Wrapper::Map r; return std::make_unique(std::move(r)); // <- warning here // return std::make_unique(r); // <- no warning // return Wrapper(std::move(r)); // <- no warning } ``` but the uninitialized variable is coming from std::unique_ptr. As in the original report it works with gcc 11.3, but it fails with gcc12.2 and trunk (in my case already with -O1), see https://godbolt.org/z/bfo9vsEPc I attached the .ii produced by my test case.
[Bug c++/107138] [12/13 regression] std::variant triggers false-positive 'may be used uninitialized' warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107138 --- Comment #5 from Marco Clemencic --- I forgot to mention that I compiled with the options: g++ -c -Wmaybe-uninitialized -O1 -v -save-temps test.cpp
[Bug c++/107138] [12/13 regression] std::variant triggers false-positive 'may be used uninitialized' warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107138 --- Comment #6 from Marco Clemencic --- I seem to be stumbling on more and more of these spurious warnings. The latest one is from a header that is found in a directory added to the search path with "-isystem", and in all cases the warnings talk about methods and functions that are "inlined from ...". I didn't manage to produce a minimal test case proving it, but I start suspecting that "-isystem" is ignored (in some circumstances) when functions get inlined.