public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107623] New: Using a parameter pack twice results in ambiguous overloaded function.
@ 2022-11-10 20:15 jlaros at fixedpoint dot nl
  2022-11-10 20:33 ` [Bug c++/107623] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: jlaros at fixedpoint dot nl @ 2022-11-10 20:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107623
           Summary: Using a parameter pack twice results in ambiguous
                    overloaded function.
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlaros at fixedpoint dot nl
  Target Milestone: ---

The following example does not compile:

    template <class R, class... Args>
    void test(R (*)(Args...), Args...) {}

    template <class... Args>
    void test(void (*)(Args...), Args...) {}

    int main() {
      void (*f)(int) {};
      test(f, 1);
    }

Example:

    $ g++ -Wall -Wextra -pedantic x.cc
    x.cc: In function ‘int main()’:
    x.cc:11:7: error: call of overloaded ‘test(void (*&)(int), int)’ is
ambiguous
       11 |   test(f, 1);
          |   ~~~~^~~~~~
    x.cc:2:6: note: candidate: ‘void test(R (*)(Args ...), Args ...) [with R =
void; Args = {int}]’
        2 | void test(R (*)(Args...), Args...) {}
          |      ^~~~
    x.cc:5:6: note: candidate: ‘void test(void (*)(Args ...), Args ...) [with
Args = {int}]’
        5 | void test(void (*)(Args...), Args...) {}
          |      ^~~~

This might be a bug because the following variants on the same theme do compile
without errors or warnings:

    template <class R, class T>
    void test(R (*)(T), T) {}

    template <class T>
    void test(void (*)(T), T) {}

And:

    template <class R, class... FArgs, class... Args>
    void test(R (*)(FArgs...), Args...) {}

    template <class... FArgs, class... Args>
    void test(void (*)(FArgs...), Args...) {}

The first example does compile when using clang (version 14.0.6).

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

end of thread, other threads:[~2022-11-10 20:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-10 20:15 [Bug c++/107623] New: Using a parameter pack twice results in ambiguous overloaded function jlaros at fixedpoint dot nl
2022-11-10 20:33 ` [Bug c++/107623] " 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).