[Bug c++/126825] std::initializer_list is causing an instantiation constructor of pointer type for an array types too

"pinskia at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
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} };
```
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.