[Bug c++/120577] [14/15/16 Regression] Another crash with [[no_unique_address]] and constexpr functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120577 Jason Merrill changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org --- Comment #10 from Jason Merrill --- Fixed for 14.4/15.2/16.
[Bug c++/120577] [14/15/16 Regression] Another crash with [[no_unique_address]] and constexpr functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120577 --- Comment #9 from GCC Commits --- The releases/gcc-14 branch has been updated by Jason Merrill : https://gcc.gnu.org/g:3120ebf3228fde693beaafd5dcbb2aa9dfb48f46 commit r14-11908-g3120ebf3228fde693beaafd5dcbb2aa9dfb48f46 Author: Jason Merrill Date: Fri Jul 25 20:49:17 2025 -0400 c++: constexpr uninitialized union [PR120577] This was failing for two reasons: 1) We were wrongly treating the basic_string constructor as zero-initializing the object, which it doesn't. 2) Given that, when we went to look for a value for the anonymous union, we concluded that it was value-initialized, and trying to evaluate that broke because we weren't setting ctx->ctor for it. This patch fixes both issues, #1 by setting CONSTRUCTOR_NO_CLEARING and #2 by inserting a new CONSTRUCTOR for the member rather than evaluate it out of context, which is consistent with cxx_eval_store_expression. PR c++/120577 gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_call_expression): Set CONSTRUCTOR_NO_CLEARING on initial value for ctor. (cxx_eval_component_reference): Make value-initialization of an aggregate member explicit. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/constexpr-union9.C: New test. (cherry picked from commit f23b5df56e237df9f66b615ca4babc564d5f75de)
[Bug c++/120577] [14/15/16 Regression] Another crash with [[no_unique_address]] and constexpr functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120577 --- Comment #8 from GCC Commits --- The releases/gcc-15 branch has been updated by Jason Merrill : https://gcc.gnu.org/g:6f0c68450871de6ea211748294c63c73e3e82748 commit r15-10067-g6f0c68450871de6ea211748294c63c73e3e82748 Author: Jason Merrill Date: Fri Jul 25 15:57:26 2025 -0400 c++: constexpr uninitialized union [PR120577] This was failing for two reasons: 1) We were wrongly treating the basic_string constructor as zero-initializing the object, which it doesn't. 2) Given that, when we went to look for a value for the anonymous union, we concluded that it was value-initialized, and trying to evaluate that broke because we weren't setting ctx->ctor for it. This patch fixes both issues, #1 by setting CONSTRUCTOR_NO_CLEARING and #2 by inserting a new CONSTRUCTOR for the member rather than evaluate it out of context, which is consistent with cxx_eval_store_expression. PR c++/120577 gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_call_expression): Set CONSTRUCTOR_NO_CLEARING on initial value for ctor. (cxx_eval_component_reference): Make value-initialization of an aggregate member explicit. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/constexpr-union9.C: New test. (cherry picked from commit f23b5df56e237df9f66b615ca4babc564d5f75de)
[Bug c++/120577] [14/15/16 Regression] Another crash with [[no_unique_address]] and constexpr functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120577 --- Comment #7 from Nikolas Klauser --- The patch fixes the non-reduced reproducer as well. Thanks!
[Bug c++/120577] [14/15/16 Regression] Another crash with [[no_unique_address]] and constexpr functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120577 --- Comment #6 from GCC Commits --- The trunk branch has been updated by Jason Merrill : https://gcc.gnu.org/g:f23b5df56e237df9f66b615ca4babc564d5f75de commit r16-2265-gf23b5df56e237df9f66b615ca4babc564d5f75de Author: Jason Merrill Date: Sat Jul 12 05:15:01 2025 -0400 c++: constexpr uninitialized union [PR120577] This was failing for two reasons: 1) We were wrongly treating the basic_string constructor as zero-initializing the object, which it doesn't. 2) Given that, when we went to look for a value for the anonymous union, we concluded that it was value-initialized, and trying to evaluate that broke because we weren't setting ctx->ctor for it. This patch fixes both issues, #1 by setting CONSTRUCTOR_NO_CLEARING and #2 by inserting a new CONSTRUCTOR for the member rather than evaluate it out of context, which is consistent with cxx_eval_store_expression. PR c++/120577 gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_call_expression): Set CONSTRUCTOR_NO_CLEARING on initial value for ctor. (cxx_eval_component_reference): Make value-initialization of an aggregate member explicit. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/constexpr-union9.C: New test.
[Bug c++/120577] [14/15/16 Regression] Another crash with [[no_unique_address]] and constexpr functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120577 --- Comment #5 from Nikolas Klauser --- Is there any update on this? It'd be really nice if libc++ could be used with GCC without any crashes.
[Bug c++/120577] [14/15/16 Regression] Another crash with [[no_unique_address]] and constexpr functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120577 Patrick Palka changed: What|Removed |Added Keywords|needs-bisection | CC||jason at gcc dot gnu.org, ||ppalka at gcc dot gnu.org --- Comment #4 from Patrick Palka --- This one also started with r15-9189. And doesn't require -O to reproduce unlike PR120502.
[Bug c++/120577] [14/15/16 Regression] Another crash with [[no_unique_address]] and constexpr functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120577 --- Comment #3 from Andrew Pinski --- >I'm pretty sure it's distinct though. It seems like it since it still fails on the trunk even after the patch to fix PR120502 .
[Bug c++/120577] [14/15/16 Regression] Another crash with [[no_unique_address]] and constexpr functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120577 --- Comment #2 from Andrew Pinski --- -std=c++20 is enough for me.
[Bug c++/120577] [14/15/16 Regression] Another crash with [[no_unique_address]] and constexpr functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120577 Andrew Pinski changed: What|Removed |Added Last reconfirmed||2025-06-09 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #1 from Andrew Pinski --- Confirmed.
[Bug c++/120577] [14/15/16 Regression] Another crash with [[no_unique_address]] and constexpr functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120577 Andrew Pinski changed: What|Removed |Added Keywords||needs-bisection Known to fail||14.3.0, 15.1.0 Known to work||14.2.0 Target Milestone|--- |14.4 Summary|Another crash with |[14/15/16 Regression] |[[no_unique_address]] and |Another crash with |constexpr functions |[[no_unique_address]] and ||constexpr functions
