https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127005
Drea Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|tree-optimization |libstdc++
--- Comment #2 from Drea Pinski <pinskia at gcc dot gnu.org> ---
Over to libstdc++ because I have a question here about std::optional behavior:
Take:
```
#include <optional>
struct s1
{
~s1();
};
std::optional<s1> t;
s1::~s1()
{
__builtin_printf("%d\n", (int)t.has_value());
}
int main()
{
t = s1{};
t.reset();
}
```
What should this print?
libstdc++ prints:
1
0
while libc++ prints:
1
1
That is does the object t have a value while executing the destructor of s1
while the call when t.reset is called or not? Or is that undefined? Or
unspecified?
Either way adding the store to _M_engaged (false) after the destructor call
will fix the warning. The question I am curious about is should there be one
before too?