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.
Confirmed.
Started with r179156. Much earlier than bug 84651.
Mine.
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
Fixed in trunk so far.
GCC 6 branch is being closed
The GCC 7 branch is being closed, re-targeting to GCC 8.4.
GCC 8.4.0 has been released, adjusting target milestone.
The GCC 8 branch is being closed, fixed in GCC 9.1.