public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111662] New: Rejects valid: cv-qualifiers are not removed from function parameters of variadic templated function types
@ 2023-10-02 11:42 janschultke at googlemail dot com
  2023-10-02 11:43 ` [Bug c++/111662] " janschultke at googlemail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: janschultke at googlemail dot com @ 2023-10-02 11:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111662

            Bug ID: 111662
           Summary: Rejects valid: cv-qualifiers are not removed from
                    function parameters of variadic templated function
                    types
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: janschultke at googlemail dot com
  Target Milestone: ---

## Code to reproduce

template<class... Ts>
void f(Ts...) {}

void(*pfi)(int) = &f<int>; // OK
void(*pfci)(int) = &f<const int>; // error

void(*pcfi)(const int) = &f<int>; // OK
void(*pcfci)(const int) = &f<const int>; // error

> <source>:5:21: error: no matches converting function 'f' to type 'void (*)(int)'
>     5 | void(*pfci)(int) = &f<const int>; // error
>       |                     ^~~~~~~~~~~~
> <source>:2:6: note: candidate is: 'template<class ... Ts> void f(Ts ...)'
>     2 | void f(Ts...) {}
>       |      ^

## Explanation

The error is nonsensical because the type of &f<const int> is already
void(*)(int). No conversion is required.

According to [dcl.fct] p5, cv-qualifiers are not part of the function type:
> After producing the list of parameter types,
> any top-level cv-qualifiers modifying a parameter type are deleted
> when forming the function type.

Variadic function templates are not exempt from this rule, and GCC should not
reject this code. Making f non-templated, or using a single T parameter instead
of a Ts... parameter pack makes this code compile.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/111662] Rejects valid: cv-qualifiers are not removed from function parameters of variadic templated function types
  2023-10-02 11:42 [Bug c++/111662] New: Rejects valid: cv-qualifiers are not removed from function parameters of variadic templated function types janschultke at googlemail dot com
@ 2023-10-02 11:43 ` janschultke at googlemail dot com
  2023-10-02 11:46 ` janschultke at googlemail dot com
  2023-10-02 17:43 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: janschultke at googlemail dot com @ 2023-10-02 11:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111662

--- Comment #1 from Jan Schultke <janschultke at googlemail dot com> ---
See https://godbolt.org/z/Kaf7jETaY

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/111662] Rejects valid: cv-qualifiers are not removed from function parameters of variadic templated function types
  2023-10-02 11:42 [Bug c++/111662] New: Rejects valid: cv-qualifiers are not removed from function parameters of variadic templated function types janschultke at googlemail dot com
  2023-10-02 11:43 ` [Bug c++/111662] " janschultke at googlemail dot com
@ 2023-10-02 11:46 ` janschultke at googlemail dot com
  2023-10-02 17:43 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: janschultke at googlemail dot com @ 2023-10-02 11:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111662

--- Comment #2 from Jan Schultke <janschultke at googlemail dot com> ---
Bug was originally discovered here:
https://stackoverflow.com/questions/77214665/problem-creating-template-function-alias-with-const-value-template-arguments/77215223#77215223

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/111662] Rejects valid: cv-qualifiers are not removed from function parameters of variadic templated function types
  2023-10-02 11:42 [Bug c++/111662] New: Rejects valid: cv-qualifiers are not removed from function parameters of variadic templated function types janschultke at googlemail dot com
  2023-10-02 11:43 ` [Bug c++/111662] " janschultke at googlemail dot com
  2023-10-02 11:46 ` janschultke at googlemail dot com
@ 2023-10-02 17:43 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-02 17:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111662

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 60608.

*** This bug has been marked as a duplicate of bug 60608 ***

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-10-02 17:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-02 11:42 [Bug c++/111662] New: Rejects valid: cv-qualifiers are not removed from function parameters of variadic templated function types janschultke at googlemail dot com
2023-10-02 11:43 ` [Bug c++/111662] " janschultke at googlemail dot com
2023-10-02 11:46 ` janschultke at googlemail dot com
2023-10-02 17:43 ` pinskia 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).