[Bug c++/101717] [12 Regression] ICE capturing static member within stateless generic lambda
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717 --- Comment #5 from Steven Sun --- (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.
[Bug c++/101717] [12 Regression] ICE capturing static member within stateless generic lambda
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717 --- Comment #4 from Andrew Pinski --- (In reply to Steven Sun from comment #3) > By the way, does anyone know other magics like g:hash? r works for the old Subversion revisions "PR" and "bug " (maybe one more) puts a link to the other bug. rN- (and rN--H) 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).
[Bug c++/101717] [12 Regression] ICE capturing static member within stateless generic lambda
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717 Steven Sun changed: What|Removed |Added CC||StevenSun2021 at hotmail dot com --- Comment #3 from Steven Sun --- 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?
[Bug c++/101717] [12 Regression] ICE capturing static member within stateless generic lambda
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717 Andrew Pinski changed: What|Removed |Added Ever confirmed|0 |1 Last reconfirmed||2021-08-02 Status|UNCONFIRMED |NEW
[Bug c++/101717] [12 Regression] ICE capturing static member within stateless generic lambda
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717 Andrew Pinski 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 --- Confirmed, GCC 11.2 compiles it cleanly. So this is a regression.