[llvm-bugs] [Bug 49869] New: Overload resolution with using-declaration and constraints doesn't consider base function template
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Apr 6 14:17:24 PDT 2021
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: unassignedclangbugs at nondot.org
Reporter: barry.revzin at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210406/382843d0/attachment.html>
More information about the llvm-bugs
mailing list