Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
timsong-cpp opened this issue Oct 24, 2023 · 1 comment · Fixed by #75569
Closed
Assignees
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@timsong-cpp
Copy link

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.

@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed new issue labels Oct 24, 2023
@llvmbot
Copy link
Member

llvmbot commented Oct 24, 2023

@llvm/issue-subscribers-clang-frontend

Author: None (timsong-cpp)

```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 `&lt;memory_resource&gt;` in GCC 13's libstdc++, which defines `polymorphic_allocator` first before adding a default template argument in a later declaration.
</details>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
4 participants