https://bugs.llvm.org/show_bug.cgi?id=49869
Bug ID: 49869
Summary: Overload resolution with using-declaration and
constraints doesn't consider base function template
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: C++2a
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
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.
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs