Bug 87425 - [9 Regression] ICE with virtual assignment operator
Summary: [9 Regression] ICE with virtual assignment operator
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: 9.0
Assignee: Marek Polacek
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2018-09-24 20:25 UTC by Volker Reichelt
Modified: 2018-09-25 18:06 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-09-25 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2018-09-24 20:25:13 UTC
The following valid code snippet (compiled with "-std=c++2a") triggers an ICE on trunk:

=================================
struct A
{
  virtual A& operator= (int);
};

struct B
{
  A a;
  B() { a = 0; }
};
=================================

bug.cc: In constructor 'B::B()':
bug.cc:9:14: internal compiler error: Segmentation fault
9 |   B() { a = 0; }
  |              ^
0xed7eef crash_signal
        ../../gcc/gcc/toplev.c:325
0x8760fc tree_check(tree_node*, char const*, int, char const*, tree_code)
        ../../gcc/gcc/tree.h:3112
0x8760fc cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.c:4821
0x8791be cxx_eval_outermost_constant_expr
        ../../gcc/gcc/cp/constexpr.c:5018
0x87c6fc maybe_constant_init_1
        ../../gcc/gcc/cp/constexpr.c:5366
0x8914f0 cp_get_fndecl_from_callee(tree_node*, bool)
        ../../gcc/gcc/cp/cvt.c:967
0x8915fb maybe_warn_nodiscard
        ../../gcc/gcc/cp/cvt.c:1016
0x891ea7 convert_to_void(tree_node*, impl_conv_void, int)
        ../../gcc/gcc/cp/cvt.c:1398
0x9c15a0 finish_expr_stmt(tree_node*)
        ../../gcc/gcc/cp/semantics.c:686
0x93e977 cp_parser_statement
        ../../gcc/gcc/cp/parser.c:10963
0x93fe98 cp_parser_statement_seq_opt
        ../../gcc/gcc/cp/parser.c:11302
0x93ff7f cp_parser_compound_statement
        ../../gcc/gcc/cp/parser.c:11256
0x956100 cp_parser_function_body
        ../../gcc/gcc/cp/parser.c:21930
0x956100 cp_parser_ctor_initializer_opt_and_function_body
        ../../gcc/gcc/cp/parser.c:21967
0x956970 cp_parser_function_definition_after_declarator
        ../../gcc/gcc/cp/parser.c:26982
0x9585ec cp_parser_late_parsing_for_member
        ../../gcc/gcc/cp/parser.c:27862
0x94b1ff cp_parser_class_specifier_1
        ../../gcc/gcc/cp/parser.c:22906
0x94c1eb cp_parser_class_specifier
        ../../gcc/gcc/cp/parser.c:22932
0x94c1eb cp_parser_type_specifier
        ../../gcc/gcc/cp/parser.c:16920
0x958d19 cp_parser_decl_specifier_seq
        ../../gcc/gcc/cp/parser.c:13757
Please submit a full bug report, [etc.]

This seems to be related to PR87398.
Comment 1 Martin Liška 2018-09-25 07:38:33 UTC
Started with the same revision r264408, thus I guess so.
Comment 2 Marek Polacek 2018-09-25 13:43:33 UTC
It's a different problem than in PR87398.
Comment 3 Marek Polacek 2018-09-25 15:04:20 UTC
Jakub's patch <https://gcc.gnu.org/ml/gcc-patches/2018-09/msg01445.html> fixes this, too, so I'll just add the new test.
Comment 4 Marek Polacek 2018-09-25 18:03:18 UTC
Author: mpolacek
Date: Tue Sep 25 18:02:47 2018
New Revision: 264581

URL: https://gcc.gnu.org/viewcvs?rev=264581&root=gcc&view=rev
Log:
	PR c++/87425
	* g++.dg/cpp2a/constexpr-virtual12.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/cpp2a/constexpr-virtual12.C
Modified:
    trunk/gcc/testsuite/ChangeLog
Comment 5 Marek Polacek 2018-09-25 18:06:49 UTC
Done.  Thanks Jakub for fixing this one.