public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94501] New: bogus "no matches converting function ... to type ..." error with variadic function template
@ 2020-04-06 13:11 ppalka at gcc dot gnu.org
  2021-08-23 21:12 ` [Bug c++/94501] arrays are not decaying to pointers in variadic function template for conversion to a function pointer pinskia at gcc dot gnu.org
  2021-09-05 11:27 ` nickhuang99 at hotmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-04-06 13:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94501
           Summary: bogus "no matches converting function ... to type ..."
                    error with variadic function template
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppalka at gcc dot gnu.org
  Target Milestone: ---

$ cat testcase.C
template<typename... Ts>
void foo(Ts...);

int main()
{
  void (*f)(int*) = foo<int[]>;
}
$ g++ -std=c++11 testcase.C
testcase.C: In function ‘int main()’:
testcase.C:6:21: error: no matches converting function ‘foo’ to type ‘void
(*)(int*)’
    6 |   void (*f)(int*) = foo<int[]>;
      |                     ^~~~~~~~~~
testcase.C:2:6: note: candidate is: ‘template<class ... Ts> void foo(Ts ...)’
    2 | void foo(Ts...);
      |      ^~~


But if we replace the template parameter pack Ts with an ordinary template
parameter T then the testcase compiles successfully.  The fact that we perform
array-to-pointer decaying of "int[]" after substituting into the function
parameter pack seems to be relevant here.

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

* [Bug c++/94501] arrays are not decaying to pointers in variadic function template for conversion to a function pointer
  2020-04-06 13:11 [Bug c++/94501] New: bogus "no matches converting function ... to type ..." error with variadic function template ppalka at gcc dot gnu.org
@ 2021-08-23 21:12 ` pinskia at gcc dot gnu.org
  2021-09-05 11:27 ` nickhuang99 at hotmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-23 21:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-08-23
             Blocks|                            |24666
     Ever confirmed|0                           |1
            Summary|bogus "no matches           |arrays are not decaying to
                   |converting function ... to  |pointers in variadic
                   |type ..." error with        |function template for
                   |variadic function template  |conversion to a function
                   |                            |pointer
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24666
[Bug 24666] [meta-bug] array decaying to pointers

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

* [Bug c++/94501] arrays are not decaying to pointers in variadic function template for conversion to a function pointer
  2020-04-06 13:11 [Bug c++/94501] New: bogus "no matches converting function ... to type ..." error with variadic function template ppalka at gcc dot gnu.org
  2021-08-23 21:12 ` [Bug c++/94501] arrays are not decaying to pointers in variadic function template for conversion to a function pointer pinskia at gcc dot gnu.org
@ 2021-09-05 11:27 ` nickhuang99 at hotmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: nickhuang99 at hotmail dot com @ 2021-09-05 11:27 UTC (permalink / raw)
  To: gcc-bugs

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

qingzhe huang <nickhuang99 at hotmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nickhuang99 at hotmail dot com

--- Comment #2 from qingzhe huang <nickhuang99 at hotmail dot com> ---
I believe this case of no specialization matching error is related with this
bug(clang passed, MSVC++ failed like GCC https://godbolt.org/z/KTahxj868). 
Possibly it is a duplicate case. However, I can see even though the root cause
are all from template substitution, the "implicit_convert" and
"determine_specialization" are two different path. Should we dup this or create
a new, considering the fix might be quite different in these two cases? Do we
force developper to fix both cases when submitting a patch?




template<typename ...Ts>
void foo(Ts...);
template<>
void foo<int[]>(int*){}


<source>:3:19: error: no matches converting function 'foo' to type 'void
(*)(int*)'
    3 | void (*f)(int*) = foo<int[]>;
      |                   ^~~~~~~~~~
<source>:2:6: note: candidate is: 'template<class ... Ts> void foo(Ts ...)'
    2 | void foo(Ts...);
      |      ^~~
<source>:5:6: error: template-id 'foo<int [3]>' for 'void foo(int*)' does not
match any template declaration
    5 | void foo<int[3]>(int*){}
      |      ^~~~~~~~~~~
<source>:2:6: note: candidate is: 'template<class ... Ts> void foo(Ts ...)'
    2 | void foo(Ts...);
      |      ^~~

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

end of thread, other threads:[~2021-09-05 11:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-06 13:11 [Bug c++/94501] New: bogus "no matches converting function ... to type ..." error with variadic function template ppalka at gcc dot gnu.org
2021-08-23 21:12 ` [Bug c++/94501] arrays are not decaying to pointers in variadic function template for conversion to a function pointer pinskia at gcc dot gnu.org
2021-09-05 11:27 ` nickhuang99 at hotmail dot com

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).