Skip to content

Using a designated-initializer-list as a template argument makes the function call ambiguous #166784

@ckwastra

Description

@ckwastra

Test code (CE):

struct A {
  int a;
};
struct B {
  int b;
};
template <A> void f();
template <B> void f();

// ✓ - GCC/Clang: OK
// ✗ - EDG:
//     - error: expected an expression
//     - error: expected a ")"
// ✗ - MSVC: https://developercommunity.visualstudio.com/t/Using-an-initializer-list-as-a-template/10994813
using T1 = decltype(f<{.a = 42}>());
using T2 = decltype(f<A{.a = 42}>()); // OK

// ✓ - GCC: OK
// ✗ - Clang:
//     - error: call to 'f' is ambiguous
//     - note: candidate function [with $0 = A{0}]
//     - note: candidate function [with $0 = B{42}]
// ✗ - EDG/MSVC: same as for `T1` above
using T3 = decltype(f<{.b = 42}>());
using T4 = decltype(f<B{.b = 42}>()); // OK

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions