* [Bug c++/101717] ICE capturing static member within stateless generic lambda
2021-08-02 0:21 [Bug c++/101717] New: ICE capturing static member by ref within stateless lambda johelegp at gmail dot com
@ 2021-08-02 0:24 ` johelegp at gmail dot com
2021-08-02 17:17 ` [Bug c++/101717] [12 Regression] " pinskia at gcc dot gnu.org
` (13 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: johelegp at gmail dot com @ 2021-08-02 0:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717
Johel Ernesto Guerrero Peña <johelegp at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|ICE capturing static member |ICE capturing static member
|by ref within stateless |within stateless generic
|lambda |lambda
--- Comment #1 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
A bit simpler and a clarification: capturing at all within a generic stateless
lambda. https://godbolt.org/z/q11fT7MM8.
```C++
struct x {
static void f() { }
void (*_)() = [] { [=](auto) { f(); }(0); };
};
```
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/101717] [12 Regression] ICE capturing static member within stateless generic lambda
2021-08-02 0:21 [Bug c++/101717] New: ICE capturing static member by ref within stateless lambda johelegp at gmail dot com
2021-08-02 0:24 ` [Bug c++/101717] ICE capturing static member within stateless generic lambda johelegp at gmail dot com
@ 2021-08-02 17:17 ` pinskia at gcc dot gnu.org
2021-08-02 17:17 ` pinskia at gcc dot gnu.org
` (12 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-02 17:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|ICE capturing static member |[12 Regression] ICE
|within stateless generic |capturing static member
|lambda |within stateless generic
| |lambda
Version|11.0 |12.0
Target Milestone|--- |12.0
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, GCC 11.2 compiles it cleanly. So this is a regression.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/101717] [12 Regression] ICE capturing static member within stateless generic lambda
2021-08-02 0:21 [Bug c++/101717] New: ICE capturing static member by ref within stateless lambda johelegp at gmail dot com
2021-08-02 0:24 ` [Bug c++/101717] ICE capturing static member within stateless generic lambda johelegp at gmail dot com
2021-08-02 17:17 ` [Bug c++/101717] [12 Regression] " pinskia at gcc dot gnu.org
@ 2021-08-02 17:17 ` pinskia at gcc dot gnu.org
2021-08-03 22:23 ` StevenSun2021 at hotmail dot com
` (11 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-02 17:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2021-08-02
Status|UNCONFIRMED |NEW
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/101717] [12 Regression] ICE capturing static member within stateless generic lambda
2021-08-02 0:21 [Bug c++/101717] New: ICE capturing static member by ref within stateless lambda johelegp at gmail dot com
` (2 preceding siblings ...)
2021-08-02 17:17 ` pinskia at gcc dot gnu.org
@ 2021-08-03 22:23 ` StevenSun2021 at hotmail dot com
2021-08-03 22:51 ` pinskia at gcc dot gnu.org
` (10 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: StevenSun2021 at hotmail dot com @ 2021-08-03 22:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717
Steven Sun <StevenSun2021 at hotmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |StevenSun2021 at hotmail dot com
--- Comment #3 from Steven Sun <StevenSun2021 at hotmail dot com> ---
This bug is not introduced in GCC 12.
The relevant code fragment is last edited by g:91e534b0d
in `gcc/cp/lambda.c`
```
gcc_checking_assert
(init && (TREE_TYPE (TREE_TYPE (init))
== current_nonlambda_class_type ()));
```
The assertion fails since long ago. (init == 0 in this case)
Before GCC 12, the `gcc_checking_assert` is `(void)0` in release version,
leaving everything fine. Somehow `gcc_checking_assert` starts working now, and
aborts the program.
My insight on the problem:
The program seems never think of a situation "a lambda inside a lambda inside a
NSDMI`. We need to amend the logic here.
"here" means
https://gcc.gnu.org/git?p=gcc.git;a=blob;f=gcc/cp/lambda.c;h=2e9d38bbe832702804ddcaffc4024ce930a74843;hb=refs/heads/master#l755
By the way, does anyone know other magics like g:hash?
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/101717] [12 Regression] ICE capturing static member within stateless generic lambda
2021-08-02 0:21 [Bug c++/101717] New: ICE capturing static member by ref within stateless lambda johelegp at gmail dot com
` (3 preceding siblings ...)
2021-08-03 22:23 ` StevenSun2021 at hotmail dot com
@ 2021-08-03 22:51 ` pinskia at gcc dot gnu.org
2021-08-03 23:28 ` StevenSun2021 at hotmail dot com
` (9 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-03 22:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Steven Sun from comment #3)
> By the way, does anyone know other magics like g:hash?
rNNNN works for the old Subversion revisions
"PRNNNN" and "bug NNNN" (maybe one more) puts a link to the other bug.
rN-NNNN (and rN-NNNN-HHHHH) works if you know the new scheme of git revisions
(git gcc-descr can find that for you and you can undo them with gcc-undescr)
I think those are all of the ones which we added to bugzilla, everything else
is standard (e.g. comment #0 works).
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/101717] [12 Regression] ICE capturing static member within stateless generic lambda
2021-08-02 0:21 [Bug c++/101717] New: ICE capturing static member by ref within stateless lambda johelegp at gmail dot com
` (4 preceding siblings ...)
2021-08-03 22:51 ` pinskia at gcc dot gnu.org
@ 2021-08-03 23:28 ` StevenSun2021 at hotmail dot com
2021-12-29 0:03 ` [Bug c++/101717] [9/10/11/12 " pinskia at gcc dot gnu.org
` (8 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: StevenSun2021 at hotmail dot com @ 2021-08-03 23:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717
--- Comment #5 from Steven Sun <StevenSun2021 at hotmail dot com> ---
(In reply to Andrew Pinski from comment #4)
Thanks!
(In reply to myself from comment #3)
> The program seems never think of a situation "a lambda inside a lambda
> inside a NSDMI`. We need to amend the logic here.
edit to:
The program seems never think of a situation "member function call inside a
generic lambda inside a lambda inside a NSDMI`. We need to amend the logic
here.
-------------------------------------
The direct cause of failure is in g:91e534b0d
```
if (!containing_function && !COMPLETE_TYPE_P (closure))
/* If we're parsing a lambda in a non-local class,
we can find the fake 'this' in scope_chain. */
init = scope_chain->x_current_class_ptr;
```
This part of logic is to find the potential `this` since there is a (static)
member function call `f`. Refer to the following comments:
/* For the overload resolution we need to find the actual `this`
that would be captured if the call turns out to be to a
non-static member function. Do not actually capture it at this
point. */
// in function `build_new_method_call_1` in `gcc/cp/call.c`
-------------------------------------
As for example in comment 1:
`scope_chain->x_current_class_ptr` is correctly set when parsing
```
[=](auto) { f(); }
```
But it was soon incorrectly set when instantiating the same lambda, i.e.
parsing
```
[=](auto) { f(); }()
```
This failure only affectes the potential `this` pointer inside the
```
[=](auto) { f(); }
```
But since here needs no `this` pointer, deleting that problematical
`gcc_checking_assert` is actually a potential fix for this problem.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/101717] [9/10/11/12 Regression] ICE capturing static member within stateless generic lambda
2021-08-02 0:21 [Bug c++/101717] New: ICE capturing static member by ref within stateless lambda johelegp at gmail dot com
` (5 preceding siblings ...)
2021-08-03 23:28 ` StevenSun2021 at hotmail dot com
@ 2021-12-29 0:03 ` pinskia at gcc dot gnu.org
2022-01-17 13:58 ` rguenth at gcc dot gnu.org
` (7 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-29 0:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2021-08-02 00:00:00 |2021-12-28
Target Milestone|12.0 |9.5
Keywords| |ice-checking,
| |needs-bisection
Summary|[12 Regression] ICE |[9/10/11/12 Regression] ICE
|capturing static member |capturing static member
|within stateless generic |within stateless generic
|lambda |lambda
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/101717] [9/10/11/12 Regression] ICE capturing static member within stateless generic lambda
2021-08-02 0:21 [Bug c++/101717] New: ICE capturing static member by ref within stateless lambda johelegp at gmail dot com
` (6 preceding siblings ...)
2021-12-29 0:03 ` [Bug c++/101717] [9/10/11/12 " pinskia at gcc dot gnu.org
@ 2022-01-17 13:58 ` rguenth at gcc dot gnu.org
2022-01-31 15:59 ` marxin at gcc dot gnu.org
` (6 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-17 13:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/101717] [9/10/11/12 Regression] ICE capturing static member within stateless generic lambda
2021-08-02 0:21 [Bug c++/101717] New: ICE capturing static member by ref within stateless lambda johelegp at gmail dot com
` (7 preceding siblings ...)
2022-01-17 13:58 ` rguenth at gcc dot gnu.org
@ 2022-01-31 15:59 ` marxin at gcc dot gnu.org
2022-04-07 2:00 ` jason at gcc dot gnu.org
` (5 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-01-31 15:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org,
| |marxin at gcc dot gnu.org
Keywords|needs-bisection |
--- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r9-279-g86cf10840b6cfbfe.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/101717] [9/10/11/12 Regression] ICE capturing static member within stateless generic lambda
2021-08-02 0:21 [Bug c++/101717] New: ICE capturing static member by ref within stateless lambda johelegp at gmail dot com
` (8 preceding siblings ...)
2022-01-31 15:59 ` marxin at gcc dot gnu.org
@ 2022-04-07 2:00 ` jason at gcc dot gnu.org
2022-04-07 3:26 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2022-04-07 2:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/101717] [9/10/11/12 Regression] ICE capturing static member within stateless generic lambda
2021-08-02 0:21 [Bug c++/101717] New: ICE capturing static member by ref within stateless lambda johelegp at gmail dot com
` (9 preceding siblings ...)
2022-04-07 2:00 ` jason at gcc dot gnu.org
@ 2022-04-07 3:26 ` cvs-commit at gcc dot gnu.org
2022-04-12 20:14 ` [Bug c++/101717] [9/10/11 " cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-07 3:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:8e4339f5023286d25c7dfa40b4c88e63b780cfd7
commit r12-8036-g8e4339f5023286d25c7dfa40b4c88e63b780cfd7
Author: Jason Merrill <jason@redhat.com>
Date: Wed Apr 6 22:20:49 2022 -0400
c++: nested generic lambda in DMI [PR101717]
We were already checking COMPLETE_TYPE_P to recognize instantiation of a
generic lambda, but didn't consider that we might be nested in a
non-generic
lambda.
PR c++/101717
gcc/cp/ChangeLog:
* lambda.cc (lambda_expr_this_capture): Check all enclosing
lambdas for completeness.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/lambda-generic-this4.C: New test.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/101717] [9/10/11 Regression] ICE capturing static member within stateless generic lambda
2021-08-02 0:21 [Bug c++/101717] New: ICE capturing static member by ref within stateless lambda johelegp at gmail dot com
` (10 preceding siblings ...)
2022-04-07 3:26 ` cvs-commit at gcc dot gnu.org
@ 2022-04-12 20:14 ` cvs-commit at gcc dot gnu.org
2022-05-12 21:15 ` [Bug c++/101717] [9/10 " cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-12 20:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:eea5641912b914f3589ec1ec576a596451180baa
commit r11-9824-geea5641912b914f3589ec1ec576a596451180baa
Author: Jason Merrill <jason@redhat.com>
Date: Wed Apr 6 22:20:49 2022 -0400
c++: nested generic lambda in DMI [PR101717]
We were already checking COMPLETE_TYPE_P to recognize instantiation of a
generic lambda, but didn't consider that we might be nested in a
non-generic
lambda.
PR c++/101717
gcc/cp/ChangeLog:
* lambda.c (lambda_expr_this_capture): Check all enclosing
lambdas for completeness.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/lambda-generic-this4.C: New test.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/101717] [9/10 Regression] ICE capturing static member within stateless generic lambda
2021-08-02 0:21 [Bug c++/101717] New: ICE capturing static member by ref within stateless lambda johelegp at gmail dot com
` (11 preceding siblings ...)
2022-04-12 20:14 ` [Bug c++/101717] [9/10/11 " cvs-commit at gcc dot gnu.org
@ 2022-05-12 21:15 ` cvs-commit at gcc dot gnu.org
2022-05-13 17:41 ` [Bug c++/101717] [9 " cvs-commit at gcc dot gnu.org
2022-05-13 17:47 ` jason at gcc dot gnu.org
14 siblings, 0 replies; 16+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-12 21:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:20dc7a2119cc0a4e5ddc4a6899a7350621f05440
commit r10-10721-g20dc7a2119cc0a4e5ddc4a6899a7350621f05440
Author: Jason Merrill <jason@redhat.com>
Date: Wed Apr 6 22:20:49 2022 -0400
c++: nested generic lambda in DMI [PR101717]
We were already checking COMPLETE_TYPE_P to recognize instantiation of a
generic lambda, but didn't consider that we might be nested in a
non-generic
lambda.
PR c++/101717
gcc/cp/ChangeLog:
* lambda.c (lambda_expr_this_capture): Check all enclosing
lambdas for completeness.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/lambda-generic-this4.C: New test.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/101717] [9 Regression] ICE capturing static member within stateless generic lambda
2021-08-02 0:21 [Bug c++/101717] New: ICE capturing static member by ref within stateless lambda johelegp at gmail dot com
` (12 preceding siblings ...)
2022-05-12 21:15 ` [Bug c++/101717] [9/10 " cvs-commit at gcc dot gnu.org
@ 2022-05-13 17:41 ` cvs-commit at gcc dot gnu.org
2022-05-13 17:47 ` jason at gcc dot gnu.org
14 siblings, 0 replies; 16+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-13 17:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:7ce3d2ab2a1a144f94a3a9be716fb831cb76603b
commit r9-10168-g7ce3d2ab2a1a144f94a3a9be716fb831cb76603b
Author: Jason Merrill <jason@redhat.com>
Date: Wed Apr 6 22:20:49 2022 -0400
c++: nested generic lambda in DMI [PR101717]
We were already checking COMPLETE_TYPE_P to recognize instantiation of a
generic lambda, but didn't consider that we might be nested in a
non-generic
lambda.
PR c++/101717
gcc/cp/ChangeLog:
* lambda.c (lambda_expr_this_capture): Check all enclosing
lambdas for completeness.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/lambda-generic-this4.C: New test.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/101717] [9 Regression] ICE capturing static member within stateless generic lambda
2021-08-02 0:21 [Bug c++/101717] New: ICE capturing static member by ref within stateless lambda johelegp at gmail dot com
` (13 preceding siblings ...)
2022-05-13 17:41 ` [Bug c++/101717] [9 " cvs-commit at gcc dot gnu.org
@ 2022-05-13 17:47 ` jason at gcc dot gnu.org
14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2022-05-13 17:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #11 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 9.5/10.4/11.3/12.
^ permalink raw reply [flat|nested] 16+ messages in thread