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

* [Bug c++/107623] Using a parameter pack twice results in ambiguous overloaded function.
  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 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-10 20:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
On the trunk (with --enable-checking=yes) we get an ICE:
<source>: In function 'int main()':
<source>:10:11: internal compiler error: in comptypes, at cp/typeck.cc:1684
   10 |       test(f, 1);
      |       ~~~~^~~~~~
0x23961de internal_error(char const*, ...)
        ???:0
0xaaa542 fancy_abort(char const*, int, char const*)
        ???:0
0xce0f15 more_specialized_fn(tree_node*, tree_node*, int)
        ???:0
0xad8609 build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ???:0
0xd01048 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ???:0
0xc88297 c_parse_file()
        ???:0
0xdd1699 c_common_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See https://gcc.gnu.org/bugs/ for instructions.
ASM generation compiler returned: 1

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