<div dir="auto"><div><br><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Mon, 20 Apr 2026, 22:25 Patrick Palka, <<a href="mailto:ppalka@redhat.com">ppalka@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Tested on x86_64-pc-linux-gnu, does this look OK for trunk?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">OK</div><div dir="auto"><br></div><div dir="auto">(We could use addressof instead of __addressof as they're equally efficient nowadays, and I think we could just use & here? But it's fine as is.)</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
-- >8 --<br>
<br>
It turns out a union without an active member does not violate C++20 core<br>
constant expression rules and r16-8748 was really just a workaround for<br>
a front end bug. The actual underlying problem -- that the constexpr<br>
evaluator treated an explicitly destroyed union member as still active<br>
-- has been fixed by r16-8767 which makes this workaround unnecessary<br>
for GCC. Rather than remove the workaround, restrict it to Clang which<br>
seems to have a similar bug.<br>
<br>
PR c++/124910<br>
<br>
libstdc++-v3/ChangeLog:<br>
<br>
* include/std/optional (_Optional_payload_base::_M_destroy):<br>
Restrict r16-8748 workaround to Clang, and adjust comment.<br>
---<br>
libstdc++-v3/include/std/optional | 5 ++---<br>
1 file changed, 2 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional<br>
index 49ba7b6b45dd..b9cc019feff7 100644<br>
--- a/libstdc++-v3/include/std/optional<br>
+++ b/libstdc++-v3/include/std/optional<br>
@@ -321,10 +321,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION<br>
{<br>
_M_engaged = false;<br>
_M_payload._M_value.~_Stored_type();<br>
-#if __cpp_lib_optional >= 202106L // full constexpr support<br>
+#if defined(__clang__) && __cpp_lib_optional >= 202106L // full constexpr support<br>
if (std::is_constant_evaluated())<br>
- // Ensure union _M_payload always has an active member, for sake<br>
- // of the core constant expression requirements.<br>
+ // Work around PR124910 for Clang.<br>
std::construct_at(std::__addressof(_M_payload._M_empty));<br>
#endif<br>
}<br>
-- <br>
2.54.0.rc1.54.g60f07c4f5c<br>
<br>
</blockquote></div></div></div>