https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105842
Bug ID: 105842
Summary: rejects-valid: static member function overload set
constrained by concepts for class template results in
ambiguous call
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: joeloser at fastmail dot com
Target Milestone: ---
In the following snippet,
```
#include <concepts>
#include <cstddef>
template<class>
struct S {
static constexpr auto f(const std::unsigned_integral auto value) ->
std::size_t {
return {};
}
static constexpr auto f(const std::signed_integral auto value) -> std::size_t
{
return f(static_cast<std::size_t>(value));
}
};
```
The second `f` overload results in a compilation error:
```
error: call of overloaded ‘f(std::size_t)’ is ambiguous
... list of the two candidates
```
This appears to be a GCC bug, but only if S is a class template (regardless of
whether the template parameter list is a type or a non-type). Note that clang
trunk compiles the code fine as-is. If `S` is a class and not a class template,
then GCC accepts the code.
See it live at https://godbolt.org/z/oddxEWGMv