Skip to content

Default template arguments added in later redeclaration not considered for CTAD #69987

Closed
@timsong-cpp

Description

@timsong-cpp
template<class> struct X {};
template<class=void> struct X;

X x;

Accepted by GCC and MSVC, rejected by Clang:

<source>:4:3: error: no viable constructor or deduction guide for deduction of template arguments of 'X'
    4 | X x;
      |   ^
<source>:1:24: note: candidate template ignored: couldn't infer template argument ''
    1 | template<class> struct X {};
      |                        ^
<source>:1:24: note: candidate function template not viable: requires 1 argument, but 0 were provided
    1 | template<class> struct X {};
      |                        ^
1 error generated.
Compiler returned: 1

This affects <memory_resource> in GCC 13's libstdc++, which defines polymorphic_allocator first before adding a default template argument in a later declaration.

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