Bug 107291 - [12/13/14 Regression] ICE in build_comparison_op, at cp/method.cc:1461 since r12-4202-g09d886e671f2230a
Summary: [12/13/14 Regression] ICE in build_comparison_op, at cp/method.cc:1461 since ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 13.0
: P4 normal
Target Milestone: 12.4
Assignee: Jason Merrill
URL:
Keywords: error-recovery, ice-on-invalid-code
: 110837 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-10-17 11:17 UTC by Arseny Solokha
Modified: 2024-02-06 03:42 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-02-06 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arseny Solokha 2022-10-17 11:17:37 UTC
g++ 13.0.0 20221016 snapshot (g:6366e3e8847af98d4728d55951534769d034d02a) ICEs when compiling the following testcase, extracted from test/CXX/class/class.compare/class.compare.default/p1.cpp from the flang 15.0.1 test suite, w/ -std=c++20:

struct S4;
bool operator==(S4 const &, S4 const &) = default;

% g++-13 -std=c++20 -c ean6w24q.cpp
ean6w24q.cpp:2:6: error: defaulted 'bool operator==(const S4&, const S4&)' is not a friend of 'S4'
    2 | bool operator==(S4 const &, S4 const &) = default;
      |      ^~~~~~~~
ean6w24q.cpp: In function 'constexpr bool operator==(const S4&, const S4&)':
ean6w24q.cpp:2:6: internal compiler error: in build_comparison_op, at cp/method.cc:1461
0x6eb1f1 build_comparison_op(tree_node*, bool, int)
	/var/tmp/portage/sys-devel/gcc-13.0.0_p20221016/work/gcc-13-20221016/gcc/cp/method.cc:1461
0xa8dc5e synthesize_method(tree_node*)
	/var/tmp/portage/sys-devel/gcc-13.0.0_p20221016/work/gcc-13-20221016/gcc/cp/method.cc:1823
0xa34889 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
	/var/tmp/portage/sys-devel/gcc-13.0.0_p20221016/work/gcc-13-20221016/gcc/cp/decl.cc:8594
0xb2ef94 cp_parser_init_declarator
	/var/tmp/portage/sys-devel/gcc-13.0.0_p20221016/work/gcc-13-20221016/gcc/cp/parser.cc:22895
0xb06cc9 cp_parser_simple_declaration
	/var/tmp/portage/sys-devel/gcc-13.0.0_p20221016/work/gcc-13-20221016/gcc/cp/parser.cc:15284
0xb3a9a1 cp_parser_declaration
	/var/tmp/portage/sys-devel/gcc-13.0.0_p20221016/work/gcc-13-20221016/gcc/cp/parser.cc:14970
0xb3b4e9 cp_parser_toplevel_declaration
	/var/tmp/portage/sys-devel/gcc-13.0.0_p20221016/work/gcc-13-20221016/gcc/cp/parser.cc:14991
0xb3b4e9 cp_parser_translation_unit
	/var/tmp/portage/sys-devel/gcc-13.0.0_p20221016/work/gcc-13-20221016/gcc/cp/parser.cc:5076
0xb3b4e9 c_parse_file()
	/var/tmp/portage/sys-devel/gcc-13.0.0_p20221016/work/gcc-13-20221016/gcc/cp/parser.cc:48860
0xc7bab1 c_common_parse_file()
	/var/tmp/portage/sys-devel/gcc-13.0.0_p20221016/work/gcc-13-20221016/gcc/c-family/c-opts.cc:1247
Comment 1 Martin Liška 2022-10-17 12:09:50 UTC
Likely started with r12-4202-g09d886e671f2230a.
Comment 2 Richard Biener 2023-05-08 12:25:41 UTC
GCC 12.3 is being released, retargeting bugs to GCC 12.4.
Comment 3 Andrew Pinski 2023-07-28 06:42:02 UTC
*** Bug 110837 has been marked as a duplicate of this bug. ***
Comment 4 GCC Commits 2024-02-06 02:29:50 UTC
The trunk branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:c5d34912ad576be1ef19be92f7eabde54b9089eb

commit r14-8817-gc5d34912ad576be1ef19be92f7eabde54b9089eb
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Feb 5 19:56:45 2024 -0500

    c++: defaulted op== for incomplete class [PR107291]
    
    After complaining about lack of friendship, we should not try to go on and
    define the defaulted comparison operator anyway.
    
            PR c++/107291
    
    gcc/cp/ChangeLog:
    
            * method.cc (early_check_defaulted_comparison): Fail if not friend.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/spaceship-eq17.C: New test.
Comment 5 GCC Commits 2024-02-06 03:41:25 UTC
The releases/gcc-13 branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:67ac78caf31f7cb3202177e6428a46d829b70f23

commit r13-8285-g67ac78caf31f7cb3202177e6428a46d829b70f23
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Feb 5 19:56:45 2024 -0500

    c++: defaulted op== for incomplete class [PR107291]
    
    After complaining about lack of friendship, we should not try to go on and
    define the defaulted comparison operator anyway.
    
            PR c++/107291
    
    gcc/cp/ChangeLog:
    
            * method.cc (early_check_defaulted_comparison): Fail if not friend.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/spaceship-eq17.C: New test.
    
    (cherry picked from commit c5d34912ad576be1ef19be92f7eabde54b9089eb)
Comment 6 GCC Commits 2024-02-06 03:41:37 UTC
The releases/gcc-12 branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:db8d5b0ad074344559b3201e567c1e47e65d0bdd

commit r12-10138-gdb8d5b0ad074344559b3201e567c1e47e65d0bdd
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Feb 5 19:56:45 2024 -0500

    c++: defaulted op== for incomplete class [PR107291]
    
    After complaining about lack of friendship, we should not try to go on and
    define the defaulted comparison operator anyway.
    
            PR c++/107291
    
    gcc/cp/ChangeLog:
    
            * method.cc (early_check_defaulted_comparison): Fail if not friend.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/spaceship-eq17.C: New test.
    
    (cherry picked from commit c5d34912ad576be1ef19be92f7eabde54b9089eb)
Comment 7 Jason Merrill 2024-02-06 03:42:02 UTC
Fixed for 12.4/13.3/14.