<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58571>58571</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Using-decls for templated member functions should create ambiguity
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            c++,
            clang:frontend
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          usx95
      </td>
    </tr>
</table>

<pre>
    While trying to fix #50886, I came across some inconsistency among clang, other compilers and the standard.

```cpp
struct base {
  template <int N, int M = 1>  int foo();
};
struct bar : public base {
  using base::foo;
  template <int N, int M, int P> int foo();
};
struct baz : public base {
  using base::foo;
  template <int N, int M> int foo();
};

void func() {
  bar b;
  b.foo<10, 10>(); // clang errors while others don't.
  b.foo<10, 10, 10>();

  baz bz;
  bz.foo<10, 10>(); // no one errors but base::foo and baz::foo should be ambiguous.
}
```
https://godbolt.org/z/G7af8soW8

According to my reading of standard
* `b.foo<10,10>()` should be valid as `bar::foo` should not hide `base::foo` (different template heads).
* `bz.foo<10,10>()` should ambiguous and still `baz::foo` should not hide `base::foo` (different template heads).

Reading:
* [namespace.udecl#11.sentence-1](https://eel.is/c++draft/namespace.udecl#11.sentence-1): The set of declarations named by a [using-declarator](https://eel.is/c++draft/namespace.udecl#nt:using-declarator) that inhabits a class C does not include member functions and member function templates of a base class that correspond to (and thus would conflict with) a declaration of a function or function template in C
* [basic.scope.scope#4](https://eel.is/c++draft/basic.scope.scope#4) Two declarations [correspond](https://eel.is/c++draft/basic.scope.scope#def:correspond) if they (re)introduce the same name, unless - both declare function templates with equivalent non-object-parameter-type-lists, return types (if any), [template-head](https://eel.is/c++draft/temp.pre#nt:template-head)s, and trailing [requires-clause](https://eel.is/c++draft/temp.pre#nt:requires-clause)s (if any),
* [temp.over.link#6)(https://eel.is/c++draft/temp.over.link#6): Two [template-head](https://eel.is/c++draft/temp.pre#nt:template-head)s are [equivalent](https://eel.is/c++draft/temp.over.link#def:equivalent,template-heads) if their [template-parameter-list](https://eel.is/c++draft/temp.pre#nt:template-parameter-list)s have the same length, corresponding [template-parameter](https://eel.is/c++draft/temp.param#nt:template-parameter)s are equivalent and are both declared with [type-constraint](https://eel.is/c++draft/temp.param#nt:type-constraint)s that are equivalent if either [template-parameter](https://eel.is/c++draft/temp.param#nt:template-parameter) is declared with a [type-constraint](https://eel.is/c++draft/temp.param#nt:type-constraint), and if either [template-head](https://eel.is/c++draft/temp.pre#nt:template-head) has a [requires-clause](https://eel.is/c++draft/temp.pre#nt:requires-clause), they both have [requires-clause](https://eel.is/c++draft/temp.pre#nt:requires-clause)s and the corresponding [constraint-expression](https://eel.is/c++draft/temp.constr.decl#nt:constraint-expression)s are equivalent[.](https://eel.is/c++draft/temp.over.link#6.sentence-1)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy9V02TozYQ_TX4ojIF2Njm4MOMZyeVQ1Kp1Kb2LIQwSjAikphZz6_Pa-EPsGdrx5md3fIyIKTXr7tft0Sui_36S6VqyZzZq2bLnGal-sqCZJZGq9UiSDbsVyb4TjIujLaWWY171QjdWGWdbMSe8Z3GSlHzZkvztaukYULvWuAay3hTMAwx63DHTREG0UMQ3R2ui6j_ibbtR6wznXAs51ayYHnfDzLm5K6tucPYbKMax34nU3TzG0YeWBzMPjH_XGodJKsgyYLZYXGwfDjdn9ANlt2xtstrJa6MdZZiQaOYhB9hzt5A5XjzB7G5gczLh5B5E4f--qRVwcquEf3MoXkKVT4wmIeewCaOyBKus08neOjmEb9eC0wao5H_Z68vrwrLCt0EydKF30S7whzSZD5W-cuQzssb-DSa6UYeCeWdG4fTSxTI5wFb6a7GGGS_y9W2050Nz7EbK7d_rJxrLQF4i1td5Lp2oTYoiccX_P9lycuV1V9WQ3_uhNCmONTdbs-M5P5Jl6dqOUxP7hhMjaI1dHURDSg_8RrZ5Nav4OasmvOsRjtWqUL2U4bKwhxgFqospZF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