* [Bug c++/97700] Bogus error when a class containing a function pointer is used as a non-type template parameter
2020-11-03 14:14 [Bug c++/97700] New: Bogus error when a class containing a function pointer is used as a non-type template parameter ensadc at mailnesia dot com
@ 2020-11-03 14:21 ` ensadc at mailnesia dot com
2020-11-19 18:54 ` mpolacek at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: ensadc at mailnesia dot com @ 2020-11-03 14:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97700
ensadc at mailnesia dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=83258
--- Comment #1 from ensadc at mailnesia dot com ---
The lambda is not needed to reproduce the bug. This also triggers the error:
void fun() {}
struct S
{
void (*f)();
};
template<S> struct X {};
using x = X<S{ fun }>;
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97700] Bogus error when a class containing a function pointer is used as a non-type template parameter
2020-11-03 14:14 [Bug c++/97700] New: Bogus error when a class containing a function pointer is used as a non-type template parameter ensadc at mailnesia dot com
2020-11-03 14:21 ` [Bug c++/97700] " ensadc at mailnesia dot com
@ 2020-11-19 18:54 ` mpolacek at gcc dot gnu.org
2021-03-13 21:42 ` johelegp at gmail dot com
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-11-19 18:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97700
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-11-19
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
CC| |mpolacek at gcc dot gnu.org
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97700] Bogus error when a class containing a function pointer is used as a non-type template parameter
2020-11-03 14:14 [Bug c++/97700] New: Bogus error when a class containing a function pointer is used as a non-type template parameter ensadc at mailnesia dot com
2020-11-03 14:21 ` [Bug c++/97700] " ensadc at mailnesia dot com
2020-11-19 18:54 ` mpolacek at gcc dot gnu.org
@ 2021-03-13 21:42 ` johelegp at gmail dot com
2023-03-17 17:57 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: johelegp at gmail dot com @ 2021-03-13 21:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97700
--- Comment #3 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
This seems to be a duplicate of Bug 83258.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97700] Bogus error when a class containing a function pointer is used as a non-type template parameter
2020-11-03 14:14 [Bug c++/97700] New: Bogus error when a class containing a function pointer is used as a non-type template parameter ensadc at mailnesia dot com
` (2 preceding siblings ...)
2021-03-13 21:42 ` johelegp at gmail dot com
@ 2023-03-17 17:57 ` pinskia at gcc dot gnu.org
2023-05-09 21:23 ` mail at lboeger dot de
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-17 17:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97700
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |waffl3x at protonmail dot com
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 109168 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97700] Bogus error when a class containing a function pointer is used as a non-type template parameter
2020-11-03 14:14 [Bug c++/97700] New: Bogus error when a class containing a function pointer is used as a non-type template parameter ensadc at mailnesia dot com
` (3 preceding siblings ...)
2023-03-17 17:57 ` pinskia at gcc dot gnu.org
@ 2023-05-09 21:23 ` mail at lboeger dot de
2023-05-10 13:13 ` ppalka at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: mail at lboeger dot de @ 2023-05-09 21:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97700
--- Comment #5 from Lukas Böger <mail at lboeger dot de> ---
One part of this seems to be resolved with version 13. Below, only the lambda
use case fails to compile, whereas prior to version 13, both type aliases are
rejected:
```
void fun() {}
struct S
{
void (*f)();
};
template<S> struct X {};
using works = X<S{ fun }>;
using does_not_work = X<S{ []{}}>;
```
See https://godbolt.org/z/3E7WE6zKo
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97700] Bogus error when a class containing a function pointer is used as a non-type template parameter
2020-11-03 14:14 [Bug c++/97700] New: Bogus error when a class containing a function pointer is used as a non-type template parameter ensadc at mailnesia dot com
` (4 preceding siblings ...)
2023-05-09 21:23 ` mail at lboeger dot de
@ 2023-05-10 13:13 ` ppalka at gcc dot gnu.org
2023-05-11 14:05 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-05-10 13:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97700
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ppalka at gcc dot gnu.org
--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Partially fixed by r13-6970-gb5e38b1c166357
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97700] Bogus error when a class containing a function pointer is used as a non-type template parameter
2020-11-03 14:14 [Bug c++/97700] New: Bogus error when a class containing a function pointer is used as a non-type template parameter ensadc at mailnesia dot com
` (5 preceding siblings ...)
2023-05-10 13:13 ` ppalka at gcc dot gnu.org
@ 2023-05-11 14:05 ` cvs-commit at gcc dot gnu.org
2023-05-11 14:25 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-11 14:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97700
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:c3afdb8ba8f1839544c414f57e41a58c8fda5349
commit r14-708-gc3afdb8ba8f1839544c414f57e41a58c8fda5349
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu May 11 10:04:25 2023 -0400
c++: converted lambda as template argument [PR83258, ...]
r8-1253-g3d2e25a240c711 removed the template argument linkage requirement
in convert_nontype_argument for C++17 (which r9-3836-g4be5c72cf3ea3e later
factored out into invalid_tparm_referent_p), but we need to also remove
the one in convert_nontype_argument_function for benefit of the first and
third testcase which we currently reject even in C++17/20 mode.
And in invalid_tparm_referent_p we're inadvertendly returning false for
the address of a lambda's static op() since it's DECL_ARTIFICIAL, which
currently causes us to reject the second (C++20) testcase. But this
DECL_ARTIFICIAL check seems to be relevant only for VAR_DECL, and in fact
this code path was originally reachable only for VAR_DECL until recently
(r13-6970-gb5e38b1c166357). So this patch restricts the check to VAR_DECL.
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
PR c++/83258
PR c++/80488
PR c++/97700
gcc/cp/ChangeLog:
* pt.cc (convert_nontype_argument_function): Remove linkage
requirement for C++17 and later.
(invalid_tparm_referent_p) <case ADDR_EXPR>: Restrict
DECL_ARTIFICIAL rejection test to VAR_DECL.
gcc/testsuite/ChangeLog:
* g++.dg/ext/visibility/anon8.C: Don't expect a "no linkage"
error for the template argument &B2:fn in C++17 mode.
* g++.dg/cpp0x/lambda/lambda-conv15.C: New test.
* g++.dg/cpp2a/nontype-class56.C: New test.
* g++.dg/template/function2.C: New test.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97700] Bogus error when a class containing a function pointer is used as a non-type template parameter
2020-11-03 14:14 [Bug c++/97700] New: Bogus error when a class containing a function pointer is used as a non-type template parameter ensadc at mailnesia dot com
` (6 preceding siblings ...)
2023-05-11 14:05 ` cvs-commit at gcc dot gnu.org
@ 2023-05-11 14:25 ` ppalka at gcc dot gnu.org
2023-05-12 15:08 ` cvs-commit at gcc dot gnu.org
2023-05-12 15:25 ` ppalka at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-05-11 14:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97700
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Target Milestone|--- |13.2
--- Comment #8 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed on trunk so far.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97700] Bogus error when a class containing a function pointer is used as a non-type template parameter
2020-11-03 14:14 [Bug c++/97700] New: Bogus error when a class containing a function pointer is used as a non-type template parameter ensadc at mailnesia dot com
` (7 preceding siblings ...)
2023-05-11 14:25 ` ppalka at gcc dot gnu.org
@ 2023-05-12 15:08 ` cvs-commit at gcc dot gnu.org
2023-05-12 15:25 ` ppalka at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-12 15:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97700
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:42f9b481be3527b336b800128247d053fd18d121
commit r13-7324-g42f9b481be3527b336b800128247d053fd18d121
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu May 11 10:04:25 2023 -0400
c++: converted lambda as template argument [PR83258, ...]
r8-1253-g3d2e25a240c711 removed the template argument linkage requirement
in convert_nontype_argument for C++17 (which r9-3836-g4be5c72cf3ea3e later
factored out into invalid_tparm_referent_p), but we need to also remove
the one in convert_nontype_argument_function for benefit of the first and
third testcase which we currently reject even in C++17/20 mode.
And in invalid_tparm_referent_p we're inadvertendly returning false for
the address of a lambda's static op() since it's DECL_ARTIFICIAL, which
currently causes us to reject the second (C++20) testcase. But this
DECL_ARTIFICIAL check seems to be relevant only for VAR_DECL, and in fact
this code path was originally reachable only for VAR_DECL until recently
(r13-6970-gb5e38b1c166357). So this patch restricts the check to VAR_DECL.
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
PR c++/83258
PR c++/80488
PR c++/97700
gcc/cp/ChangeLog:
* pt.cc (convert_nontype_argument_function): Remove linkage
requirement for C++17 and later.
(invalid_tparm_referent_p) <case ADDR_EXPR>: Restrict
DECL_ARTIFICIAL rejection test to VAR_DECL.
gcc/testsuite/ChangeLog:
* g++.dg/ext/visibility/anon8.C: Don't expect a "no linkage"
error for the template argument &B2:fn in C++17 mode.
* g++.dg/cpp0x/lambda/lambda-conv15.C: New test.
* g++.dg/cpp2a/nontype-class56.C: New test.
* g++.dg/template/function2.C: New test.
(cherry picked from commit c3afdb8ba8f1839544c414f57e41a58c8fda5349)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/97700] Bogus error when a class containing a function pointer is used as a non-type template parameter
2020-11-03 14:14 [Bug c++/97700] New: Bogus error when a class containing a function pointer is used as a non-type template parameter ensadc at mailnesia dot com
` (8 preceding siblings ...)
2023-05-12 15:08 ` cvs-commit at gcc dot gnu.org
@ 2023-05-12 15:25 ` ppalka at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-05-12 15:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97700
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #10 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Should be fully fixed for GCC 13.2
^ permalink raw reply [flat|nested] 11+ messages in thread