<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Overload resolution with using-declaration and constraints doesn't consider base function template"
   href="https://bugs.llvm.org/show_bug.cgi?id=49869">49869</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Overload resolution with using-declaration and constraints doesn't consider base function template
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++2a
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>barry.revzin@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider:

#include <concepts>

struct A {};

struct Base {
#ifdef OK
    static constexpr int foo(int) { return 1; }
#else
    static constexpr int foo(auto) { return 1; }
#endif
};

struct Derived : Base {
    using Base::foo;
    template <std::same_as<A> T>
    static constexpr int foo(T) { return 2; }
};

static_assert(Derived::foo(42) == 1);
static_assert(Derived::foo(A{}) == 2);

With -DOK this compiles. Otherwise, the call to Derived::foo(42) fails with

<source>:19:15: error: no matching function for call to 'foo'
static_assert(Derived::foo(42) == 1);
              ^~~~~~~~~~~~
<source>:16:26: note: candidate template ignored: constraints not satisfied
[with T = int]
    static constexpr int foo(T) { return 2; }
                         ^
<source>:15:20: note: because 'std::same_as<int, A>' evaluated to false
    template <std::same_as<A> T>
                   ^

The base candidate is considered and used when it's not a template, but not
considered at all when it is a template. This seems related to whether the
Derived function template uses constraints or not.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>