public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "StevenSun2021 at hotmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/101717] [12 Regression] ICE capturing static member within stateless generic lambda
Date: Tue, 03 Aug 2021 23:28:22 +0000 [thread overview]
Message-ID: <bug-101717-4-mnDxYptYei@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101717-4@http.gcc.gnu.org/bugzilla/>
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.
next prev parent reply other threads:[~2021-08-03 23:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
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
2021-08-03 22:51 ` pinskia at gcc dot gnu.org
2021-08-03 23:28 ` StevenSun2021 at hotmail dot com [this message]
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
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
2022-05-12 21:15 ` [Bug c++/101717] [9/10 " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-101717-4-mnDxYptYei@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).