* [Bug c++/108242] '__FUNCTION__' was not declared when used inside a generic (templated) lambda declared inside a template function
2022-12-28 16:13 [Bug c++/108242] New: '__FUNCTION__' was not declared when used inside a lambda declared inside a template function n.eugene536 at gmail dot com
@ 2022-12-28 17:50 ` pinskia at gcc dot gnu.org
2022-12-28 17:54 ` [Bug c++/108242] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-28 17:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108242
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|'__FUNCTION__' was not |'__FUNCTION__' was not
|declared when used inside a |declared when used inside a
|templated lambda declared |generic (templated) lambda
|inside a template function |declared inside a template
| |function
Known to fail| |11.3.0
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced slightly more:
template<int F>
void my_fun()
{
[&](auto) {
static constexpr char const* fun_name = __func__;
struct t
{
t() { fun_name; };
} t1;
}(12);
}
int main() {
my_fun<1>();
}
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/108242] [10/11/12/13 Regression] '__FUNCTION__' was not declared when used inside a generic (templated) lambda declared inside a template function
2022-12-28 16:13 [Bug c++/108242] New: '__FUNCTION__' was not declared when used inside a lambda declared inside a template function n.eugene536 at gmail dot com
2022-12-28 17:50 ` [Bug c++/108242] '__FUNCTION__' was not declared when used inside a generic (templated) " pinskia at gcc dot gnu.org
@ 2022-12-28 17:54 ` pinskia at gcc dot gnu.org
2022-12-29 2:44 ` pinskia at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-28 17:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108242
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |needs-bisection
Target Milestone|--- |10.5
Known to work| |7.1.0
Last reconfirmed| |2022-12-28
Summary|'__FUNCTION__' was not |[10/11/12/13 Regression]
|declared when used inside a |'__FUNCTION__' was not
|generic (templated) lambda |declared when used inside a
|declared inside a template |generic (templated) lambda
|function |declared inside a template
| |function
Known to fail| |8.1.0
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note the original testcase works in GCC 8 to GCC 11 while my testcase in
comment #1 fails with those versions.
Would be interesting to see what patch broke the original testcase and my
testcase.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/108242] [10/11/12/13 Regression] '__FUNCTION__' was not declared when used inside a generic (templated) lambda declared inside a template function
2022-12-28 16:13 [Bug c++/108242] New: '__FUNCTION__' was not declared when used inside a lambda declared inside a template function n.eugene536 at gmail dot com
2022-12-28 17:50 ` [Bug c++/108242] '__FUNCTION__' was not declared when used inside a generic (templated) " pinskia at gcc dot gnu.org
2022-12-28 17:54 ` [Bug c++/108242] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org
@ 2022-12-29 2:44 ` pinskia at gcc dot gnu.org
2023-01-02 9:27 ` jakub at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-29 2:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108242
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=84925,
| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=82029
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
related to PR 84925 and PR 82029 . The first one was caused by the second one
and the second one was caused by r8-2720-gf44a8dd56f5bfb which I suspect might
have introduced this bug ...
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/108242] [10/11/12/13 Regression] '__FUNCTION__' was not declared when used inside a generic (templated) lambda declared inside a template function
2022-12-28 16:13 [Bug c++/108242] New: '__FUNCTION__' was not declared when used inside a lambda declared inside a template function n.eugene536 at gmail dot com
` (2 preceding siblings ...)
2022-12-29 2:44 ` pinskia at gcc dot gnu.org
@ 2023-01-02 9:27 ` jakub at gcc dot gnu.org
2023-01-09 14:03 ` rguenth at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-02 9:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108242
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|needs-bisection |
CC| |jakub at gcc dot gnu.org
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The original testcase started to be rejected with
r12-4425-g1595fe44e11a969d8ae462212886fb0a87b46226
The second one indeed starting with
r8-2720-gf44a8dd56f5bfbd0596c39693e268ef880c06221
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/108242] [10/11/12/13 Regression] '__FUNCTION__' was not declared when used inside a generic (templated) lambda declared inside a template function
2022-12-28 16:13 [Bug c++/108242] New: '__FUNCTION__' was not declared when used inside a lambda declared inside a template function n.eugene536 at gmail dot com
` (3 preceding siblings ...)
2023-01-02 9:27 ` jakub at gcc dot gnu.org
@ 2023-01-09 14:03 ` rguenth at gcc dot gnu.org
2023-02-03 18:09 ` jakub at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-01-09 14:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108242
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/108242] [10/11/12/13 Regression] '__FUNCTION__' was not declared when used inside a generic (templated) lambda declared inside a template function
2022-12-28 16:13 [Bug c++/108242] New: '__FUNCTION__' was not declared when used inside a lambda declared inside a template function n.eugene536 at gmail dot com
` (4 preceding siblings ...)
2023-01-09 14:03 ` rguenth at gcc dot gnu.org
@ 2023-02-03 18:09 ` jakub at gcc dot gnu.org
2023-02-03 18:16 ` mpolacek at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-03 18:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108242
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Makes me wonder why finish_fname returns the IDENTIFIER_NODE rather than the
VAR_DECL when processing_template_decl, though if I comment that out it ICEs.
When DECL_INITIAL is __FUNCTION__ etc. IDENTIFIER_NODE, it is looked up using
lookup_name, which works fine if it is the template function in which
__FUNCTION__ has been referenced (ok e.g. when processing DECL_EXPR of
fun_name). But for some reason
we don't find that VAR_DECL as local specialization and trigger
/* This can happen for a variable used in a
late-specified return type of a local lambda, or for a
local static or constant. Building a new VAR_DECL
should be OK in all those cases. */
r = tsubst_decl (t, args, complain);
if (local_specializations)
/* Avoid infinite recursion (79640). */
register_local_specialization (r, t);
if (decl_maybe_constant_var_p (r))
{
/* We can't call cp_finish_decl, so handle the
initializer by hand. */
tree init = tsubst_init (DECL_INITIAL (t), r, args,
complain, in_decl);
which then doesn't work, either it finds a different __FUNCTION__ than it
should, e.g. for:
bool v;
template<class F>
void my_fun()
{
auto fun = [&](auto res) {
static constexpr char const* fun_name = __FUNCTION__;
struct
{
constexpr const char* operator()() const { return v ? __FUNCTION__
: fun_name; };
} t;
t();
};
fun(12);
}
or it doesn't find it at all.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/108242] [10/11/12/13 Regression] '__FUNCTION__' was not declared when used inside a generic (templated) lambda declared inside a template function
2022-12-28 16:13 [Bug c++/108242] New: '__FUNCTION__' was not declared when used inside a lambda declared inside a template function n.eugene536 at gmail dot com
` (5 preceding siblings ...)
2023-02-03 18:09 ` jakub at gcc dot gnu.org
@ 2023-02-03 18:16 ` mpolacek at gcc dot gnu.org
2023-02-03 18:23 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-02-03 18:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108242
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=105809
CC| |mpolacek at gcc dot gnu.org
--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I was just looking into bug 105809 which looks like the same problem except
with __PRETTY_FUNCTION__.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/108242] [10/11/12/13 Regression] '__FUNCTION__' was not declared when used inside a generic (templated) lambda declared inside a template function
2022-12-28 16:13 [Bug c++/108242] New: '__FUNCTION__' was not declared when used inside a lambda declared inside a template function n.eugene536 at gmail dot com
` (6 preceding siblings ...)
2023-02-03 18:16 ` mpolacek at gcc dot gnu.org
@ 2023-02-03 18:23 ` jakub at gcc dot gnu.org
2023-03-16 19:15 ` jason at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-03 18:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108242
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Sorry, above doesn't compile, but
template<class F>
void my_fun()
{
auto fun = [&](auto res) {
static constexpr char const* fun_name = __PRETTY_FUNCTION__;
struct
{
constexpr const char* operator()() const { constexpr char const*
fun_name2 = __PRETTY_FUNCTION__; return fun_name; };
} t;
t();
};
fun(12);
}
int main() {
my_fun<int>();
}
ICEs and compiles fine with G++ 11.x.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/108242] [10/11/12/13 Regression] '__FUNCTION__' was not declared when used inside a generic (templated) lambda declared inside a template function
2022-12-28 16:13 [Bug c++/108242] New: '__FUNCTION__' was not declared when used inside a lambda declared inside a template function n.eugene536 at gmail dot com
` (7 preceding siblings ...)
2023-02-03 18:23 ` jakub at gcc dot gnu.org
@ 2023-03-16 19:15 ` jason at gcc dot gnu.org
2023-03-16 22:11 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2023-03-16 19:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108242
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] 13+ messages in thread
* [Bug c++/108242] [10/11/12/13 Regression] '__FUNCTION__' was not declared when used inside a generic (templated) lambda declared inside a template function
2022-12-28 16:13 [Bug c++/108242] New: '__FUNCTION__' was not declared when used inside a lambda declared inside a template function n.eugene536 at gmail dot com
` (8 preceding siblings ...)
2023-03-16 19:15 ` jason at gcc dot gnu.org
@ 2023-03-16 22:11 ` cvs-commit at gcc dot gnu.org
2023-04-18 20:46 ` [Bug c++/108242] [10/11/12 " cvs-commit at gcc dot gnu.org
2023-07-07 10:44 ` [Bug c++/108242] [11 " rguenth at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-16 22:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108242
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:b323f52ccf966800297b0520b9e1d4b3951db525
commit r13-6722-gb323f52ccf966800297b0520b9e1d4b3951db525
Author: Jason Merrill <jason@redhat.com>
Date: Thu Mar 16 15:11:25 2023 -0400
c++: generic lambda, local class, __func__ [PR108242]
Here we are trying to do name lookup in a deferred instantiation of t() and
failing to find __func__. tsubst_expr already tries to instantiate members
of local classes, but was failing with the partial instantiation of generic
lambdas.
PR c++/108242
gcc/cp/ChangeLog:
* pt.cc (tsubst_expr) [TAG_DEFN]: Handle partial instantiation.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/lambda-generic-func2.C: New test.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/108242] [10/11/12 Regression] '__FUNCTION__' was not declared when used inside a generic (templated) lambda declared inside a template function
2022-12-28 16:13 [Bug c++/108242] New: '__FUNCTION__' was not declared when used inside a lambda declared inside a template function n.eugene536 at gmail dot com
` (9 preceding siblings ...)
2023-03-16 22:11 ` cvs-commit at gcc dot gnu.org
@ 2023-04-18 20:46 ` cvs-commit at gcc dot gnu.org
2023-07-07 10:44 ` [Bug c++/108242] [11 " rguenth at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-18 20:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108242
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:890d711a2477119a34cf435f6159b6253b124374
commit r12-9437-g890d711a2477119a34cf435f6159b6253b124374
Author: Jason Merrill <jason@redhat.com>
Date: Thu Mar 16 15:11:25 2023 -0400
c++: generic lambda, local class, __func__ [PR108242]
Here we are trying to do name lookup in a deferred instantiation of t() and
failing to find __func__. tsubst_expr already tries to instantiate members
of local classes, but was failing with the partial instantiation of generic
lambdas.
PR c++/108242
gcc/cp/ChangeLog:
* pt.cc (tsubst_expr) [TAG_DEFN]: Handle partial instantiation.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/lambda-generic-func2.C: New test.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/108242] [11 Regression] '__FUNCTION__' was not declared when used inside a generic (templated) lambda declared inside a template function
2022-12-28 16:13 [Bug c++/108242] New: '__FUNCTION__' was not declared when used inside a lambda declared inside a template function n.eugene536 at gmail dot com
` (10 preceding siblings ...)
2023-04-18 20:46 ` [Bug c++/108242] [10/11/12 " cvs-commit at gcc dot gnu.org
@ 2023-07-07 10:44 ` rguenth at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108242
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.5 |11.5
--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.
^ permalink raw reply [flat|nested] 13+ messages in thread