https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109339
Bug ID: 109339
Summary: stop_token compiled with -Og yields
maybe-uninitialized
Product: gcc
Version: 12.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: gcc at heine dot tech
Target Milestone: ---
This happens since gcc 12.
This snippet compiled with -std=c++20 -Og -Wmaybe-uninitialized
```
#include <stop_token>
int main() {
std::stop_source ss;
}
```
yields this warning
```
In constructor 'std::stop_source::stop_source()',
inlined from 'int main()' at <source>:4:22:
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/stop_token:480:21:
warning: 'ss' may be used uninitialized [-Wmaybe-uninitialized]
480 | stop_source() : _M_state(*this)
| ^~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/stop_token: In function
'int main()':
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/stop_token:397:7: note: by
argument 2 of type 'const std::stop_source&' to
'std::stop_token::_Stop_state_ref::_Stop_state_ref(const std::stop_source&)'
declared here
397 | _Stop_state_ref(const stop_source&)
| ^~~~~~~~~~~~~~~
<source>:4:22: note: 'ss' declared here
4 | std::stop_source ss;
| ^~
```
Godbolt: https://godbolt.org/z/KofErdEzY