public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch] PR 82293 ("[8 Regression] ICE in nonlambda_method_basetype at gcc/cp/lambda.c:886")
@ 2017-11-22 14:55 Paolo Carlini
  2017-11-29 21:31 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Carlini @ 2017-11-22 14:55 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill, Nathan Sidwell

[-- Attachment #1: Type: text/plain, Size: 706 bytes --]

Hi,

this ICE on valid is triggered by the existing 
cpp0x/lambda/lambda-ice20.C when -Wshadow is requested. Today I 
confirmed that it can be reproduced only after r251433, the "Reimplement 
handling of lambdas in templates." patch: then, as part of 
tsubst_lambda_expr, do_pushdecl calls check_local_shadow which in turn 
checks nonlambda_method_basetype and at that time current_class_type is 
null. I believe this is just something which we have to handle in the 
obvious way: indeed, most other uses of LAMBDA_TYPE_P are already 
checking first that the argument is non-null, see, for example, the 
related current_nonlambda_class_type. Tested x86_64-linux.

Thanks, Paolo.

///////////////////////



[-- Attachment #2: CL_82293 --]
[-- Type: text/plain, Size: 280 bytes --]

/cp
2017-11-22  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/82293
	* lambda.c (nonlambda_method_basetype): Don't use LAMBDA_TYPE_P
	on a null type.

/testsuite
2017-11-22  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/82293
	* g++.dg/cpp0x/lambda/lambda-ice24.C: New.

[-- Attachment #3: patch_82293 --]
[-- Type: text/plain, Size: 870 bytes --]

Index: cp/lambda.c
===================================================================
--- cp/lambda.c	(revision 255053)
+++ cp/lambda.c	(working copy)
@@ -921,7 +921,7 @@ nonlambda_method_basetype (void)
     return NULL_TREE;
 
   type = current_class_type;
-  if (!LAMBDA_TYPE_P (type))
+  if (!type || !LAMBDA_TYPE_P (type))
     return type;
 
   /* Find the nearest enclosing non-lambda function.  */
Index: testsuite/g++.dg/cpp0x/lambda/lambda-ice24.C
===================================================================
--- testsuite/g++.dg/cpp0x/lambda/lambda-ice24.C	(nonexistent)
+++ testsuite/g++.dg/cpp0x/lambda/lambda-ice24.C	(working copy)
@@ -0,0 +1,12 @@
+// PR c++/82293
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wshadow" }
+
+template <typename>
+struct S {
+  int f{[this](){return 42;}()};
+};
+
+int main(){
+  return S<int>{}.f;
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [C++ Patch] PR 82293 ("[8 Regression] ICE in nonlambda_method_basetype at gcc/cp/lambda.c:886")
  2017-11-22 14:55 [C++ Patch] PR 82293 ("[8 Regression] ICE in nonlambda_method_basetype at gcc/cp/lambda.c:886") Paolo Carlini
@ 2017-11-29 21:31 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2017-11-29 21:31 UTC (permalink / raw)
  To: Paolo Carlini; +Cc: gcc-patches, Nathan Sidwell

OK.

On Wed, Nov 22, 2017 at 9:49 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> Hi,
>
> this ICE on valid is triggered by the existing cpp0x/lambda/lambda-ice20.C
> when -Wshadow is requested. Today I confirmed that it can be reproduced only
> after r251433, the "Reimplement handling of lambdas in templates." patch:
> then, as part of tsubst_lambda_expr, do_pushdecl calls check_local_shadow
> which in turn checks nonlambda_method_basetype and at that time
> current_class_type is null. I believe this is just something which we have
> to handle in the obvious way: indeed, most other uses of LAMBDA_TYPE_P are
> already checking first that the argument is non-null, see, for example, the
> related current_nonlambda_class_type. Tested x86_64-linux.
>
> Thanks, Paolo.
>
> ///////////////////////
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-11-29 21:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-22 14:55 [C++ Patch] PR 82293 ("[8 Regression] ICE in nonlambda_method_basetype at gcc/cp/lambda.c:886") Paolo Carlini
2017-11-29 21:31 ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).