[Bug c++/113063] Strange linker error in special case involving local class with defaulted spaceship operator and static assert
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113063 --- Comment #10 from GCC Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:37977343ff4f9dcb047d966d8cbaa222964763f9 commit r15-3491-g37977343ff4f9dcb047d966d8cbaa222964763f9 Author: Patrick Palka Date: Thu Sep 5 14:31:00 2024 -0400 c++: local class memfn synth from noexcept context [PR113063] Extending the PR113063 testcase to additionally constant evaluate the <=> expression causes us to trip over the assert in cxx_eval_call_expression /* We used to shortcut trivial constructor/op= here, but nowadays we can only get a trivial function here with -fno-elide-constructors. */ gcc_checking_assert (!trivial_fn_p (fun) || !flag_elide_constructors /* We don't elide constructors when processing a noexcept-expression. */ || cp_noexcept_operand); since the local class's <=> was first used and therefore synthesized in a noexcept context and so its definition contains unelided trivial constructors. This patch fixes this by clearing cp_noexcept_operand alongside cp_unevaluated_context in the function-local case of maybe_push_to_top_level. PR c++/113063 gcc/cp/ChangeLog: * name-lookup.cc (local_state_t): Clear and restore cp_noexcept_operand as well. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/spaceship-synth16.C: Also constant evaluate the <=> expression. * g++.dg/cpp2a/spaceship-synth16a.C: Likewise. Reviewed-by: Jason Merrill
[Bug c++/113063] Strange linker error in special case involving local class with defaulted spaceship operator and static assert
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113063 Patrick Palka changed: What|Removed |Added Target Milestone|14.0|13.4 --- Comment #9 from Patrick Palka --- Fixed for 13.4 now as well. > Thanks for fixing it. Should it be back-ported to earlier GCC versions? From > my point of view, as far back as GCC 11 would be nice. We usually only backport regression fixes (or occasionally if the fix is clearly confined to experimental language support, currently C++20 or later, which isn't the case for this fix).
[Bug c++/113063] Strange linker error in special case involving local class with defaulted spaceship operator and static assert
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113063 --- Comment #8 from GCC Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:4aa89badc8c16637e0d9a39a08da7d18e209631b commit r15-2848-g4aa89badc8c16637e0d9a39a08da7d18e209631b Author: Patrick Palka Date: Fri Aug 9 09:16:45 2024 -0400 c++: add fixed testcase [PR116289] Fully fixed since r14-6724-gfced59166f95e9. PR c++/116289 PR c++/113063 gcc/testsuite/ChangeLog: * g++.dg/cpp2a/spaceship-synth16a.C: New test.
[Bug c++/113063] Strange linker error in special case involving local class with defaulted spaceship operator and static assert
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113063 --- Comment #7 from GCC Commits --- The releases/gcc-13 branch has been updated by Patrick Palka : https://gcc.gnu.org/g:12ba140ee93adc56a3426f0c6c05f4d6c6a3d08e commit r13-8967-g12ba140ee93adc56a3426f0c6c05f4d6c6a3d08e Author: Patrick Palka Date: Fri Aug 9 09:03:14 2024 -0400 c++: local class memfn synth from uneval context [PR113063] This is essentially a narrow backport of r14-6724-gfced59166f95e9 that instead uses cp_evaluated instead of maybe_push_to_top_level to clear cp_unevaluated_operand within synthesize_method, which turns out is sufficient to also fix the 13.3 regression PR116289 (whose immediate trigger is a change backport r13-7739-gd919309679334a). PR c++/113063 PR c++/116289 gcc/cp/ChangeLog: * method.cc (synthesize_method): Use cp_evaluated. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/spaceship-synth16.C: New test. * g++.dg/cpp2a/spaceship-synth16a.C: New test. Reviewed-by: Jason Merrill
[Bug c++/113063] Strange linker error in special case involving local class with defaulted spaceship operator and static assert
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113063 --- Comment #6 from Kristian Spangsege --- Thanks for fixing it. Should it be back-ported to earlier GCC versions? From my point of view, as far back as GCC 11 would be nice.
[Bug c++/113063] Strange linker error in special case involving local class with defaulted spaceship operator and static assert
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113063 Patrick Palka changed: What|Removed |Added Resolution|--- |FIXED Target Milestone|--- |14.0 Status|ASSIGNED|RESOLVED --- Comment #5 from Patrick Palka --- Fixed for GCC 14, thanks for the bug report.
[Bug c++/113063] Strange linker error in special case involving local class with defaulted spaceship operator and static assert
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113063 --- Comment #4 from GCC Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:fced59166f95e9922a72392955e4fed095afd47e commit r14-6724-gfced59166f95e9922a72392955e4fed095afd47e Author: Patrick Palka Date: Tue Dec 19 16:33:55 2023 -0500 c++: local class memfn synth from uneval context [PR113063] Here we first use and therefore synthesize the local class operator<=> from an unevaluated context, which inadvertently affects synthesization by preventing functions used within the definition (such as the copy constructor of std::strong_ordering) from getting marked as odr-used. This patch fixes this by using maybe_push_to_top_level in synthesize_method which ensures cp_unevaluated_operand gets cleared even in the function-local case. PR c++/113063 gcc/cp/ChangeLog: * method.cc (synthesize_method): Use maybe_push_to_top_level and maybe_pop_from_top_level. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/spaceship-synth16.C: New test.
[Bug c++/113063] Strange linker error in special case involving local class with defaulted spaceship operator and static assert
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113063 Patrick Palka changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org CC||ppalka at gcc dot gnu.org --- Comment #3 from Patrick Palka --- Seems the problem is that the first use of the operator<=> occurs inside an unevaluated context, and we forget to reset the context before synthesizing the function.
[Bug c++/113063] Strange linker error in special case involving local class with defaulted spaceship operator and static assert
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113063 Andrew Pinski changed: What|Removed |Added Keywords||ice-on-valid-code Status|UNCONFIRMED |NEW Last reconfirmed||2023-12-18 Ever confirmed|0 |1 --- Comment #2 from Andrew Pinski --- Confirmed, also GCC ICEs with -O1 and above (when GCC is configured with checking enabled which is the default for the trunk): ``` : In function 'int main()': :11:27: in 'constexpr' expansion of 'x.main()::X::operator<=>(x)' :7:14: internal compiler error: in cxx_eval_call_expression, at cp/constexpr.cc:3013 7 | auto operator<=>(const X&) const = default; | ^~~~ ```
[Bug c++/113063] Strange linker error in special case involving local class with defaulted spaceship operator and static assert
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113063 --- Comment #1 from Kristian Spangsege --- By the way, and as expected, this problem does not exist in Clang.