Skip to content

C++ constructor interpreted as function when rvalue and using parenthesis, preventing template deduction for aliases #114586

@mld2443

Description

@mld2443

https://godbolt.org/z/fPvqG4Txx

template <int> class A {};
A() -> A<0>;

template <int ARG>
using B = A<ARG>;

static_assert(sizeof(B()));

GCC deduces B to be a type alias for A and interprets B() as instantiation using deduction guides. clang interprets rvalue as an alias to a function instead of a type constructor, and the template argument deductions are incorrectly rejected.

In order to convince clang that B is a type and not a function, we can use braced initialization, B{}.

clang and MSVC both consider this ill-formed, however I think GCC is correct here.

Metadata

Metadata

Assignees

No one assigned

    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