Hello, I believe I've found a GCC bug.
Command line:
```
gcc -O2 -std=gnu++20 -Wmaybe-uninitialized example.cpp
```
example.cpp:
```cpp
#include <memory>
#include <optional>
using namespace std;
struct Sender {
~Sender() noexcept {
state = {};
}
optional<shared_ptr<int>> state;
};
static Sender sender{};
int main() {
}
```
Compiler output:
```
In file included from
*/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_x86_gcc_16.1.0/include/c++/16.1.0/bits/shared_ptr.h:53*,
from
*/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_x86_gcc_16.1.0/include/c++/16.1.0/memory:82*,
from *<source>:1*:
In destructor '*std::__shared_count<_Lp>::~__shared_count*() [with
__gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]',
inlined from '*std::__shared_ptr<_Tp, _Lp>::~__shared_ptr*() [with
_Tp = int; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]' at
*/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_x86_gcc_16.1.0/include/c++/16.1.0/bits/shared_ptr_base.h:1610:7*,
inlined from '*std::shared_ptr<int>::~shared_ptr*()' at
*/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_x86_gcc_16.1.0/include/c++/16.1.0/bits/shared_ptr.h:175:11*,
inlined from '*constexpr void
std::_Optional_payload_base<_Tp>::_M_destroy*() [with _Tp =
std::shared_ptr<int>]' at
*/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_x86_gcc_16.1.0/include/c++/16.1.0/optional:323:35*,
inlined from '*constexpr void
std::_Optional_payload_base<_Tp>::_M_reset*() [with _Tp =
std::shared_ptr<int>]' at
*/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_x86_gcc_16.1.0/include/c++/16.1.0/optional:359:14*,
inlined from '*constexpr void
std::_Optional_payload_base<_Tp>::_M_reset*() [with _Tp =
std::shared_ptr<int>]' at
*/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_x86_gcc_16.1.0/include/c++/16.1.0/optional:356:7*,
inlined from '*constexpr std::_Optional_payload<_Tp, false, _Copy,
_Move>::~_Optional_payload*() [with _Tp = std::shared_ptr<int>; bool
_Copy = false; bool _Move = false]' at
*/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_x86_gcc_16.1.0/include/c++/16.1.0/optional:482:65*,
inlined from '*constexpr std::_Optional_base<std::shared_ptr<int>,
false, false>::~_Optional_base*()' at
*/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_x86_gcc_16.1.0/include/c++/16.1.0/optional:506:12*,
inlined from '*constexpr std::optional<std::shared_ptr<int>
>::~optional*()' at
*/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_x86_gcc_16.1.0/include/c++/16.1.0/optional:810:11*,
inlined from '*Sender::~Sender*()' at *<source>:9:5*:
*/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_x86_gcc_16.1.0/include/c++/16.1.0/bits/shared_ptr_base.h:1135:13:*
*warning:
*'*((std::__shared_count<__gnu_cxx::_S_atomic>*)this)[1].std::__shared_count<>::_M_pi*'
may be used uninitialized [*-Wmaybe-uninitialized*]
1135 | if (*_M_pi* != nullptr)
| *^~~~~*
Compiler returned: 0
```