https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126825
Bug ID: 126825
Summary: Array decays to pointer when constructing element of
std::initializer_list
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: eczbek.void at gmail dot com
Target Milestone: ---
https://godbolt.org/z/oKWWEToaf
Clang accepts this.
```
struct A {
template<typename T>
A(T& arg) {
static_assert(std::is_same_v<T, const char[1]>);
}
};
int main() {
std::initializer_list<A> { "" };
}
```
```
<source>: In instantiation of 'A::A(T&) [with T = const char* const]':
<source>:12:32: required from here
12 | std::initializer_list<A> { "" };
| ^
<source>:7:36: error: static assertion failed
7 | static_assert(std::is_same_v<T, const char[1]>);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
• 'const char* const' is not the same as 'const char [1]'
```