[Bug c++/106110] New: Expected ambiguity but it resolves fine
ted at lyncon dot se
gcc-bugzilla@gcc.gnu.org
Mon Jun 27 21:13:57 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106110
Bug ID: 106110
Summary: Expected ambiguity but it resolves fine
Product: gcc
Version: 12.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ted at lyncon dot se
Target Milestone: ---
I made a type trait to test if a call to a function using certain arguments
would be ambiguous or not, but in the below example, where I expected that
calling the function `foo` with a `std::tuple<single_type>` would result in
ambiguity, it is not detected as such.
```
#include <iostream>
#include <tuple>
template <class T>
void foo(const std::tuple<T>&) { std::cout << "T\n"; }
template <class T, class... Ts>
void foo(const std::tuple<T, Ts...>&) { std::cout << "Ts...\n"; }
template <class... Args>
struct is_foo_call_ambiguous {
static std::true_type test(...);
template <class... AArgs>
static auto test(AArgs&&...)
-> decltype(foo(std::declval<AArgs>()...), std::false_type{});
static constexpr bool value =
decltype(test(std::declval<Args>()...))::value;
};
template <class F, class... Args>
static constexpr bool is_foo_call_ambiguous_v =
is_foo_call_ambiguous<F, Args...>::value;
int main() {
// expected `true` here, but it reports `false`:
std::cout << is_foo_call_ambiguous_v<std::tuple<int>> << '\n';
// `false` as expected:
std::cout << is_foo_call_ambiguous_v<std::tuple<int, int>> << '\n';
}
```
As can be seen here, clang++ reports it to be ambiguous:
https://godbolt.org/z/YTevWvbzz
If I understand it correctly, the added tiebreaker
(https://cplusplus.github.io/CWG/issues/1395.html) for variadic templates
should not apply here.
More information about the Gcc-bugs
mailing list