public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/97121] New: ICE (segfault) on incorrect default three-way comparison declaration @ 2020-09-19 20:37 warp at iki dot fi 2020-10-26 17:19 ` [Bug c++/97121] " mpolacek at gcc dot gnu.org ` (5 more replies) 0 siblings, 6 replies; 7+ messages in thread From: warp at iki dot fi @ 2020-09-19 20:37 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97121 Bug ID: 97121 Summary: ICE (segfault) on incorrect default three-way comparison declaration Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: warp at iki dot fi Target Milestone: --- Consider the following code (which mistakenly tries to return 'bool' from the three-way comparison rather than 'auto'): //---------------------------------------------------------- #include <compare> class MyClass { int mValue; public: MyClass(int value): mValue(value) {} bool operator<=>(const MyClass&) const = default; }; int main() { MyClass a = 10, b = 15; return (a < b); } //---------------------------------------------------------- Trying to compile it causes a segfault: ------------------------------------------------------------ test.cc: In member function ‘constexpr bool MyClass::operator<=>(const MyClass&) const’: test.cc:11:10: internal compiler error: Segmentation fault 11 | bool operator<=>(const MyClass&) const = default; | ^~~~~~~~ Please submit a full bug report, with preprocessed source if appropriate. ------------------------------------------------------------ The correct version (ie. with an 'auto' return value) compiles successfully. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/97121] ICE (segfault) on incorrect default three-way comparison declaration 2020-09-19 20:37 [Bug c++/97121] New: ICE (segfault) on incorrect default three-way comparison declaration warp at iki dot fi @ 2020-10-26 17:19 ` mpolacek at gcc dot gnu.org 2021-04-13 17:05 ` redi at gcc dot gnu.org ` (4 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: mpolacek at gcc dot gnu.org @ 2020-10-26 17:19 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97121 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 CC| |mpolacek at gcc dot gnu.org Last reconfirmed| |2020-10-26 --- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Confirmed. 97121.C: In member function ‘constexpr bool MyClass::operator<=>(const MyClass&) const’: 97121.C:10:10: internal compiler error: in genericize_spaceship, at cp/method.c:1073 10 | bool operator<=>(const MyClass&) const = default; | ^~~~~~~~ 0xb75a50 genericize_spaceship(tree_node*, tree_node*, tree_node*) /home/mpolacek/src/gcc/gcc/cp/method.c:1073 0xa53e18 genericize_spaceship /home/mpolacek/src/gcc/gcc/cp/cp-gimplify.c:901 0xa565ed cp_genericize_r /home/mpolacek/src/gcc/gcc/cp/cp-gimplify.c:1355 0x1af1612 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /home/mpolacek/src/gcc/gcc/tree.c:12008 0xd0e3c8 cp_walk_subtrees(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*) /home/mpolacek/src/gcc/gcc/cp/tree.c:5175 0x1af1722 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /home/mpolacek/src/gcc/gcc/tree.c:12031 0xa5700e cp_genericize_r /home/mpolacek/src/gcc/gcc/cp/cp-gimplify.c:1482 0x1af1612 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /home/mpolacek/src/gcc/gcc/tree.c:12008 0xa55847 cp_genericize_r /home/mpolacek/src/gcc/gcc/cp/cp-gimplify.c:1182 0x1af1612 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /home/mpolacek/src/gcc/gcc/tree.c:12008 0xa55847 cp_genericize_r /home/mpolacek/src/gcc/gcc/cp/cp-gimplify.c:1182 0x1af1612 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /home/mpolacek/src/gcc/gcc/tree.c:12008 0xa579cd cp_genericize_tree /home/mpolacek/src/gcc/gcc/cp/cp-gimplify.c:1595 0xa5859a cp_genericize(tree_node*) /home/mpolacek/src/gcc/gcc/cp/cp-gimplify.c:1741 0xad1be3 finish_function(bool) /home/mpolacek/src/gcc/gcc/cp/decl.c:17215 0xb781da synthesize_method(tree_node*) /home/mpolacek/src/gcc/gcc/cp/method.c:1612 0xc921a9 maybe_instantiate_noexcept(tree_node*, int) /home/mpolacek/src/gcc/gcc/cp/pt.c:25357 0xaf257b mark_used(tree_node*, int) /home/mpolacek/src/gcc/gcc/cp/decl2.c:5549 0x9b0bb6 build_over_call /home/mpolacek/src/gcc/gcc/cp/call.c:9149 0x9a58f7 build_new_op_1 /home/mpolacek/src/gcc/gcc/cp/call.c:6341 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/97121] ICE (segfault) on incorrect default three-way comparison declaration 2020-09-19 20:37 [Bug c++/97121] New: ICE (segfault) on incorrect default three-way comparison declaration warp at iki dot fi 2020-10-26 17:19 ` [Bug c++/97121] " mpolacek at gcc dot gnu.org @ 2021-04-13 17:05 ` redi at gcc dot gnu.org 2021-04-13 17:07 ` redi at gcc dot gnu.org ` (3 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: redi at gcc dot gnu.org @ 2021-04-13 17:05 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97121 --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- Fixed on trunk by r11-5866 c++: Fix defaulted <=> fallback to < and == [PR96299] I thought I had implemented P1186R3, but apparently I didn't read it closely enough to understand the point of the paper, namely that for a defaulted operator<=>, if a member type doesn't have a viable operator<=>, we will use its operator< and operator== if the defaulted operator has an specific comparison category as its return type; the compiler can't guess if it should be strong_ordering or something else, but the user can make that choice explicit. The libstdc++ test change was necessary because of the change in genericize_spaceship from op0 > op1 to op1 < op0; this should be equivalent, but isn't because of PR88173. We should add a test and close it. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/97121] ICE (segfault) on incorrect default three-way comparison declaration 2020-09-19 20:37 [Bug c++/97121] New: ICE (segfault) on incorrect default three-way comparison declaration warp at iki dot fi 2020-10-26 17:19 ` [Bug c++/97121] " mpolacek at gcc dot gnu.org 2021-04-13 17:05 ` redi at gcc dot gnu.org @ 2021-04-13 17:07 ` redi at gcc dot gnu.org 2021-04-13 17:13 ` redi at gcc dot gnu.org ` (2 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: redi at gcc dot gnu.org @ 2021-04-13 17:07 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97121 Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |GCCBugzilla at DRHouck dot me --- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- *** Bug 97216 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/97121] ICE (segfault) on incorrect default three-way comparison declaration 2020-09-19 20:37 [Bug c++/97121] New: ICE (segfault) on incorrect default three-way comparison declaration warp at iki dot fi ` (2 preceding siblings ...) 2021-04-13 17:07 ` redi at gcc dot gnu.org @ 2021-04-13 17:13 ` redi at gcc dot gnu.org 2021-04-13 18:43 ` cvs-commit at gcc dot gnu.org 2021-11-04 20:52 ` redi at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: redi at gcc dot gnu.org @ 2021-04-13 17:13 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97121 Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |crillion at tiscali dot it --- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- *** Bug 99086 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/97121] ICE (segfault) on incorrect default three-way comparison declaration 2020-09-19 20:37 [Bug c++/97121] New: ICE (segfault) on incorrect default three-way comparison declaration warp at iki dot fi ` (3 preceding siblings ...) 2021-04-13 17:13 ` redi at gcc dot gnu.org @ 2021-04-13 18:43 ` cvs-commit at gcc dot gnu.org 2021-11-04 20:52 ` redi at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2021-04-13 18:43 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97121 --- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:4df918798b445e86305b63f86f5312a18e4017c5 commit r11-8158-g4df918798b445e86305b63f86f5312a18e4017c5 Author: Jakub Jelinek <jakub@redhat.com> Date: Tue Apr 13 20:42:07 2021 +0200 testsuite: Add testcase for already fixed PR97121 This was fixed by r11-5866 aka PR96299 fix. 2021-04-13 Jakub Jelinek <jakub@redhat.com> PR c++/97121 * g++.dg/cpp2a/spaceship-err6.C: New test. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/97121] ICE (segfault) on incorrect default three-way comparison declaration 2020-09-19 20:37 [Bug c++/97121] New: ICE (segfault) on incorrect default three-way comparison declaration warp at iki dot fi ` (4 preceding siblings ...) 2021-04-13 18:43 ` cvs-commit at gcc dot gnu.org @ 2021-11-04 20:52 ` redi at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: redi at gcc dot gnu.org @ 2021-11-04 20:52 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97121 Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Target Milestone|--- |11.0 Resolution|--- |FIXED --- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> --- Fixed in gcc 11. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-11-04 20:52 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-09-19 20:37 [Bug c++/97121] New: ICE (segfault) on incorrect default three-way comparison declaration warp at iki dot fi 2020-10-26 17:19 ` [Bug c++/97121] " mpolacek at gcc dot gnu.org 2021-04-13 17:05 ` redi at gcc dot gnu.org 2021-04-13 17:07 ` redi at gcc dot gnu.org 2021-04-13 17:13 ` redi at gcc dot gnu.org 2021-04-13 18:43 ` cvs-commit at gcc dot gnu.org 2021-11-04 20:52 ` redi at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).