Clang accepts CTAD from inherited constructors in -std=c++20 (P2582/C++23 feature)
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Clang 19.1.7 accepts this in `-std=c++20`, including with `-pedantic-errors`:
```c++
struct Base {
Base(int*) {}
};
template
struct D : Base {
using Base::Base;
};
int main() {
D d{(int*)0};
}
```
```
clang++ -std=c++20 -c test.cpp
clang++ -std=c++20 -pedantic-errors -c test.cpp
clang++ -std=c++23 -c test.cpp
```
All three Clang commands succeed.
For comparison, local GCC 14.2.0 rejects the same code in `-std=c++20` with:
```
error: class template argument deduction failed:
error: no matching function for call to 'D(int*)'
```
This behavior corresponds to the P2582/C++23 feature area (CTAD from inherited constructors). Accepting it in `-std=c++20` may be too permissive and could lead to non-portable code. If this behavior is intentional, it would be helpful to know whether Clang treats it as an extension in pre-C++23 modes.
Relevant references:
- GCC bug c++/106653: [link](https://gcc.gnu.org/pipermail/gcc-bugs/2022-August/795585.html)
- GCC P2582R1 patch discussion: [link](https://gcc.gnu.org/pipermail/gcc-patches/2023-December/640625.html)
- P2582 wording: [link](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2582r0.pdf)
Contributor guide
Research direction
Reproduce the example in test.cpp with the three listed clang++ commands, then compare the C++20 and C++23 rules against P2582 and the linked GCC discussions. Trace Clang's handling of CTAD from inherited constructors in the language frontend; done means the behavior is confirmed as standard-conforming or extension-only in C++20, with regression coverage if a bug is established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100