Bug 84520 - [6/7/8 Regression] ICE with lambda and static member function
Summary: [6/7/8 Regression] ICE with lambda and static member function
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0
: P2 normal
Target Milestone: 6.5
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2018-02-22 18:41 UTC by Volker Reichelt
Modified: 2018-02-27 04:23 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-02-23 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-02-22 18:41:02 UTC
The following valid testcase triggers an ICE since GCC 5.1.0.
It was compiled without problems in GCC 4.9.x.

================================================
struct A
{
  static void foo(int);
  void (*f)(int) = [](auto i) { foo(i); };
};
================================================

bug.cc: In instantiation of 'A::<lambda(auto:1)> [with auto:1 = int]':
bug.cc:4:29:   required by substitution of 'template<class auto:1> A::<lambda(auto:1)>::operator decltype (((A::<lambda(auto:1)>)0u).operator()(i)) (*)(auto:1)() const [with auto:1 = int]'
bug.cc:4:41:   required from here
bug.cc:4:36: internal compiler error: in lambda_expr_this_capture, at cp/lambda.c:697
   void (*f)(int) = [](auto i) { foo(i); };
                                    ^
0x83f04c lambda_expr_this_capture(tree_node*, bool)
	../../gcc-5.1.0/gcc/cp/lambda.c:695
0x83f387 maybe_resolve_dummy(tree_node*, bool)
	../../gcc-5.1.0/gcc/cp/lambda.c:789
0x6485a1 build_new_method_call_1
	../../gcc-5.1.0/gcc/cp/call.c:8027
0x6485a1 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, tree_node*, int, tree_node**, int)
	../../gcc-5.1.0/gcc/cp/call.c:8275
0x7cd9ef finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool, bool, int)
	../../gcc-5.1.0/gcc/cp/semantics.c:2367
0x6b536f tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	../../gcc-5.1.0/gcc/cp/pt.c:15211
0x6a2a85 tsubst_expr
	../../gcc-5.1.0/gcc/cp/pt.c:14398
0x6a39b2 tsubst_expr
	../../gcc-5.1.0/gcc/cp/pt.c:13809
0x6a25fb tsubst_expr
	../../gcc-5.1.0/gcc/cp/pt.c:13981
0x6a25fb tsubst_expr
	../../gcc-5.1.0/gcc/cp/pt.c:13981
0x6a0774 instantiate_decl(tree_node*, int, bool)
	../../gcc-5.1.0/gcc/cp/pt.c:20407
0x7219f8 mark_used(tree_node*, int)
	../../gcc-5.1.0/gcc/cp/decl2.c:5029
0x63d88a build_over_call
	../../gcc-5.1.0/gcc/cp/call.c:7489
0x64889e build_new_method_call_1
	../../gcc-5.1.0/gcc/cp/call.c:8205
0x64889e build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, tree_node*, int, tree_node**, int)
	../../gcc-5.1.0/gcc/cp/call.c:8275
0x6b5fe2 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	../../gcc-5.1.0/gcc/cp/pt.c:15205
0x6aac9e tsubst(tree_node*, tree_node*, int, tree_node*)
	../../gcc-5.1.0/gcc/cp/pt.c:12530
0x6b0a5f tsubst_function_type
	../../gcc-5.1.0/gcc/cp/pt.c:11624
0x6ab365 tsubst(tree_node*, tree_node*, int, tree_node*)
	../../gcc-5.1.0/gcc/cp/pt.c:12357
0x6aac06 tsubst(tree_node*, tree_node*, int, tree_node*)
	../../gcc-5.1.0/gcc/cp/pt.c:11899
Please submit a full bug report, [etc.]
Comment 1 Jakub Jelinek 2018-02-23 12:51:29 UTC
Started with r210292, before it has been accepted.
Comment 2 Jason Merrill 2018-02-27 02:44:58 UTC
Author: jason
Date: Tue Feb 27 02:44:26 2018
New Revision: 258021

URL: https://gcc.gnu.org/viewcvs?rev=258021&root=gcc&view=rev
Log:
	PR c++/84520 - ICE with generic lambda in NSDMI.

	* lambda.c (lambda_expr_this_capture): Don't look for fake NSDMI
	'this' in a generic lambda instantiation.

Added:
    trunk/gcc/testsuite/g++.dg/cpp1y/lambda-generic-nsdmi1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/lambda.c
Comment 3 Jason Merrill 2018-02-27 02:47:56 UTC
Author: jason
Date: Tue Feb 27 02:47:25 2018
New Revision: 258024

URL: https://gcc.gnu.org/viewcvs?rev=258024&root=gcc&view=rev
Log:
	PR c++/84520 - ICE with generic lambda in NSDMI.

	* lambda.c (lambda_expr_this_capture): Don't look for fake NSDMI
	'this' in a generic lambda instantiation.

Added:
    branches/gcc-7-branch/gcc/testsuite/g++.dg/cpp1y/lambda-generic-nsdmi1.C
Modified:
    branches/gcc-7-branch/gcc/cp/ChangeLog
    branches/gcc-7-branch/gcc/cp/lambda.c
Comment 4 Jason Merrill 2018-02-27 04:22:57 UTC
Author: jason
Date: Tue Feb 27 04:22:24 2018
New Revision: 258027

URL: https://gcc.gnu.org/viewcvs?rev=258027&root=gcc&view=rev
Log:
	PR c++/84520 - ICE with generic lambda in NSDMI.

	* lambda.c (lambda_expr_this_capture): Don't look for fake NSDMI
	'this' in a generic lambda instantiation.

Added:
    branches/gcc-6-branch/gcc/testsuite/g++.dg/cpp1y/lambda-generic-nsdmi1.C
Modified:
    branches/gcc-6-branch/gcc/cp/ChangeLog
    branches/gcc-6-branch/gcc/cp/lambda.c
Comment 5 Jason Merrill 2018-02-27 04:23:23 UTC
Fixed.