https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126825
Drea Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2026-08-13
Summary|Array decays to pointer |std::initializer_list is
|when constructing element |causing an instantiation
|of std::initializer_list |constructor of pointer type
| |for an array types too
Status|UNCONFIRMED |NEW
Keywords|wrong-code |
--- Comment #1 from Drea Pinski <pinskia at gcc dot gnu.org> ---
So this is a bit odd. Because in the end only A::A<char const [1]> is called.
So seems not to have any wrong code here happening here. Just instantiation of
a constructor that is not used later on.
Note this happens with all array types not just with string constants as shown
by:
```
#include <initializer_list>
#include <type_traits>
template <class T>struct s;
template <class T, int n>
struct s<T[n]>
{
s();
//static_assert(std::is_same_v<T, const int>);
};
struct A {
template<typename T>
A(T& arg) {
static s<T> b={};
}
};
std::initializer_list<A> b { (const int[]){1,2,3}, (const int[]){4} };
```