Bug 84691 - [8 Regression] internal compiler error: in poplevel_class, at cp/name-lookup.c:4430
Summary: [8 Regression] internal compiler error: in poplevel_class, at cp/name-lookup....
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0.1
: P4 normal
Target Milestone: 9.0
Assignee: Paolo Carlini
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2018-03-03 15:09 UTC by Vegard Nossum
Modified: 2021-05-14 10:33 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-03-05 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vegard Nossum 2018-03-03 15:09:37 UTC
Input:

template<typename>
struct a {
  unsigned b = [] {
    union {
      friend void c() {}
    };
  };
};

Output:

$ xgcc -x c++ -S -
<stdin>: In lambda function:
<stdin>:5:21: error: can't define friend function 'c' in a local class definition
<stdin>: At global scope:
<stdin>:5:24: internal compiler error: in poplevel_class, at cp/name-lookup.c:4430
0xe1ebc7 poplevel_class()
        /home/vegard/git/gcc/gcc/cp/name-lookup.c:4430
0x9ccaa8 popclass()
        /home/vegard/git/gcc/gcc/cp/class.c:7419
0x9ccaa8 pop_nested_class()
        /home/vegard/git/gcc/gcc/cp/class.c:7573
0xbd1380 finish_function(bool)
        /home/vegard/git/gcc/gcc/cp/decl.c:15864
0xf9fa39 cp_parser_function_definition_after_declarator
        /home/vegard/git/gcc/gcc/cp/parser.c:26812
0xfa1cbc cp_parser_late_parsing_for_member
        /home/vegard/git/gcc/gcc/cp/parser.c:27690
0xf1aed5 cp_parser_class_specifier_1
        /home/vegard/git/gcc/gcc/cp/parser.c:22733
0xf2642b cp_parser_class_specifier
        /home/vegard/git/gcc/gcc/cp/parser.c:22759
0xf2642b cp_parser_type_specifier
        /home/vegard/git/gcc/gcc/cp/parser.c:16765
0xf8be5a cp_parser_decl_specifier_seq
        /home/vegard/git/gcc/gcc/cp/parser.c:13627
0xfa7a20 cp_parser_simple_declaration
        /home/vegard/git/gcc/gcc/cp/parser.c:12936
0xfaf948 cp_parser_block_declaration
        /home/vegard/git/gcc/gcc/cp/parser.c:12881
0xfb1e14 cp_parser_declaration_statement
        /home/vegard/git/gcc/gcc/cp/parser.c:12474
0xefdd8b cp_parser_statement
        /home/vegard/git/gcc/gcc/cp/parser.c:10923
0xf0184b cp_parser_statement_seq_opt
        /home/vegard/git/gcc/gcc/cp/parser.c:11272
0xfd36d1 cp_parser_lambda_body
        /home/vegard/git/gcc/gcc/cp/parser.c:10683
0xfd36d1 cp_parser_lambda_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:10184
0xf38814 cp_parser_primary_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:5259
0xf7a2eb cp_parser_postfix_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:7028
0xf2e057 cp_parser_unary_expression
        /home/vegard/git/gcc/gcc/cp/parser.c:8320

$ xgcc --version
xgcc (GCC) 8.0.1 20180301 (experimental)

Built from git c435a9e730c6e8f10da09d58b4fc9aaeb401b0d5 (r258097).

Seems to have been introduced between 4.6.4 and 4.7.1.

Could be related to bug #84651?

Test case was minimised by C-Reduce.
Comment 1 Marek Polacek 2018-03-05 08:26:37 UTC
Confirmed.
Comment 2 Marek Polacek 2018-03-05 08:30:32 UTC
Started with r179156.  Much earlier than bug 84651.
Comment 3 Paolo Carlini 2018-04-26 11:03:59 UTC
Mine.
Comment 4 paolo@gcc.gnu.org 2018-04-27 16:57:27 UTC
Author: paolo
Date: Fri Apr 27 16:56:55 2018
New Revision: 259716

URL: https://gcc.gnu.org/viewcvs?rev=259716&root=gcc&view=rev
Log:
/cp
2018-04-27  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/84691
	* decl.c (grokdeclarator): Clear friendp upon definition in local
	class definition error.

/testsuite
2018-04-27  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/84691
	* g++.dg/cpp0x/friend3.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/friend3.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Paolo Carlini 2018-04-27 16:58:04 UTC
Fixed in trunk so far.
Comment 6 Jakub Jelinek 2018-10-26 10:18:20 UTC
GCC 6 branch is being closed
Comment 7 Richard Biener 2019-11-14 07:48:35 UTC
The GCC 7 branch is being closed, re-targeting to GCC 8.4.
Comment 8 Jakub Jelinek 2020-03-04 09:40:11 UTC
GCC 8.4.0 has been released, adjusting target milestone.
Comment 9 Jakub Jelinek 2021-05-14 10:33:23 UTC
The GCC 8 branch is being closed, fixed in GCC 9.1.