public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/83258] Rejecting function pointer non-type template parameter without linkage
[not found] <bug-83258-4@http.gcc.gnu.org/bugzilla/>
@ 2020-03-17 18:17 ` herring at lanl dot gov
2020-08-26 15:51 ` ma.noack.pr at gmail dot com
` (10 subsequent siblings)
11 siblings, 0 replies; 12+ messages in thread
From: herring at lanl dot gov @ 2020-03-17 18:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83258
S. Davis Herring <herring at lanl dot gov> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
--- Comment #7 from S. Davis Herring <herring at lanl dot gov> ---
My example in Comment #5 works in 9.2 but not in (Compiler Explorer's) trunk.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/83258] Rejecting function pointer non-type template parameter without linkage
[not found] <bug-83258-4@http.gcc.gnu.org/bugzilla/>
2020-03-17 18:17 ` [Bug c++/83258] Rejecting function pointer non-type template parameter without linkage herring at lanl dot gov
@ 2020-08-26 15:51 ` ma.noack.pr at gmail dot com
2021-03-13 19:44 ` johelegp at gmail dot com
` (9 subsequent siblings)
11 siblings, 0 replies; 12+ messages in thread
From: ma.noack.pr at gmail dot com @ 2020-08-26 15:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83258
Matthias Noack <ma.noack.pr at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ma.noack.pr at gmail dot com
--- Comment #8 from Matthias Noack <ma.noack.pr at gmail dot com> ---
Still failing in 10.2 (original reproducer).
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/83258] Rejecting function pointer non-type template parameter without linkage
[not found] <bug-83258-4@http.gcc.gnu.org/bugzilla/>
2020-03-17 18:17 ` [Bug c++/83258] Rejecting function pointer non-type template parameter without linkage herring at lanl dot gov
2020-08-26 15:51 ` ma.noack.pr at gmail dot com
@ 2021-03-13 19:44 ` johelegp at gmail dot com
2021-03-13 21:51 ` johelegp at gmail dot com
` (8 subsequent siblings)
11 siblings, 0 replies; 12+ messages in thread
From: johelegp at gmail dot com @ 2021-03-13 19:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83258
Johel Ernesto Guerrero Peña <johelegp at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |johelegp at gmail dot com
--- Comment #9 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
I think Bug 97700 is also a duplicate of this.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/83258] Rejecting function pointer non-type template parameter without linkage
[not found] <bug-83258-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2021-03-13 19:44 ` johelegp at gmail dot com
@ 2021-03-13 21:51 ` johelegp at gmail dot com
2021-12-04 1:01 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 12+ messages in thread
From: johelegp at gmail dot com @ 2021-03-13 21:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83258
--- Comment #10 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
Another workaround, extended from Bug 92320's example. See
https://godbolt.org/z/69onWf.
You can wrap the closure object in a template function which itself invokes the
closure object and converts to a function pointer that GCC accepts.
```C++
template<auto V>
void templ() {}
void dummy(){}
template<auto F>
void fn(){F();}
void foo() {
constexpr int a = 7 + 3;
templ<a>();
templ<dummy>();
typedef void(FPtr)();
constexpr FPtr * b = &dummy;
templ<b>();
constexpr auto l = []{};
constexpr void (*d)()=fn<l>;
templ<d>();
constexpr FPtr * c = [](){};
templ<c>();
}
```
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/83258] Rejecting function pointer non-type template parameter without linkage
[not found] <bug-83258-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2021-03-13 21:51 ` johelegp at gmail dot com
@ 2021-12-04 1:01 ` pinskia at gcc dot gnu.org
2021-12-20 4:10 ` egallager at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-04 1:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83258
--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #4)
> Testcase from Bug 85589:
>
> template<auto& v> struct foo {};
>
> int main() {
> static auto v = "str";
> (void) foo<v> {};
> }
Note comment #4 is already fixed (I reopened PR 85589 to close it was fixed [or
as a dup if I can find one]).
The rest of the testcases still fail on the trunk.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/83258] Rejecting function pointer non-type template parameter without linkage
[not found] <bug-83258-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2021-12-04 1:01 ` pinskia at gcc dot gnu.org
@ 2021-12-20 4:10 ` egallager at gcc dot gnu.org
2023-05-11 14:05 ` cvs-commit at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 12+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-12-20 4:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83258
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=97700
--- Comment #12 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Johel Ernesto Guerrero Peña from comment #9)
> I think Bug 97700 is also a duplicate of this.
Well, it seems related enough, at least...
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/83258] Rejecting function pointer non-type template parameter without linkage
[not found] <bug-83258-4@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2021-12-20 4:10 ` egallager 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
` (4 subsequent siblings)
11 siblings, 0 replies; 12+ 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=83258
--- Comment #13 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] 12+ messages in thread
* [Bug c++/83258] Rejecting function pointer non-type template parameter without linkage
[not found] <bug-83258-4@http.gcc.gnu.org/bugzilla/>
` (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 12:38 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 12+ 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=83258
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |13.2
CC| |ppalka at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #14 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed on trunk so far.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/83258] Rejecting function pointer non-type template parameter without linkage
[not found] <bug-83258-4@http.gcc.gnu.org/bugzilla/>
` (7 preceding siblings ...)
2023-05-11 14:25 ` ppalka at gcc dot gnu.org
@ 2023-05-12 12:38 ` cvs-commit at gcc dot gnu.org
2023-05-12 15:08 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-12 12:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83258
--- Comment #15 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:10098788ff61467f5a499f01c5443fb53ff564dd
commit r14-787-g10098788ff61467f5a499f01c5443fb53ff564dd
Author: Patrick Palka <ppalka@redhat.com>
Date: Fri May 12 08:37:54 2023 -0400
c++: remove redundant testcase [PR83258]
I noticed only after the fact that the new testcase template/function2.C
(from r14-708-gc3afdb8ba8f183) is just a subset of ext/visibility/anon8.C,
so let's get rid of it.
PR c++/83258
gcc/testsuite/ChangeLog:
* g++.dg/ext/visibility/anon8.C: Mention PR83258.
* g++.dg/template/function2.C: Removed.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/83258] Rejecting function pointer non-type template parameter without linkage
[not found] <bug-83258-4@http.gcc.gnu.org/bugzilla/>
` (8 preceding siblings ...)
2023-05-12 12:38 ` cvs-commit at gcc dot gnu.org
@ 2023-05-12 15:08 ` cvs-commit 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
11 siblings, 0 replies; 12+ 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=83258
--- Comment #16 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] 12+ messages in thread
* [Bug c++/83258] Rejecting function pointer non-type template parameter without linkage
[not found] <bug-83258-4@http.gcc.gnu.org/bugzilla/>
` (9 preceding siblings ...)
2023-05-12 15:08 ` cvs-commit 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
11 siblings, 0 replies; 12+ 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=83258
--- Comment #17 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:20b1e1d8a79356e03f50f53e2fa02b376d56d7d7
commit r13-7327-g20b1e1d8a79356e03f50f53e2fa02b376d56d7d7
Author: Patrick Palka <ppalka@redhat.com>
Date: Fri May 12 08:37:54 2023 -0400
c++: remove redundant testcase [PR83258]
I noticed only after the fact that the new testcase template/function2.C
(from r14-708-gc3afdb8ba8f183) is just a subset of ext/visibility/anon8.C,
so let's get rid of it.
PR c++/83258
gcc/testsuite/ChangeLog:
* g++.dg/ext/visibility/anon8.C: Mention PR83258.
* g++.dg/template/function2.C: Removed.
(cherry picked from commit 10098788ff61467f5a499f01c5443fb53ff564dd)
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/83258] Rejecting function pointer non-type template parameter without linkage
[not found] <bug-83258-4@http.gcc.gnu.org/bugzilla/>
` (10 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
11 siblings, 0 replies; 12+ 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=83258
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #18 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 13.2
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-05-12 15:25 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-83258-4@http.gcc.gnu.org/bugzilla/>
2020-03-17 18:17 ` [Bug c++/83258] Rejecting function pointer non-type template parameter without linkage herring at lanl dot gov
2020-08-26 15:51 ` ma.noack.pr at gmail dot com
2021-03-13 19:44 ` johelegp at gmail dot com
2021-03-13 21:51 ` johelegp at gmail dot com
2021-12-04 1:01 ` pinskia at gcc dot gnu.org
2021-12-20 4:10 ` egallager 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
2023-05-12 12:38 ` cvs-commit at gcc dot gnu.org
2023-05-12 15:08 ` cvs-commit 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
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).