https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119561

            Bug ID: 119561
           Summary: GCC hasn't completely forbidden user-declared
                    specializations of std::initializer_list
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: de34 at live dot cn
  Target Milestone: ---

Per [initializer.list.syn]/2 (https://eel.is/c++draft/initializer.list.syn#2)
(added via LWG 2129 (https://cplusplus.github.io/LWG/issue2129)), the following
code snippet is ill-formed (neither UB nor IFNDR) and thus should be rejected.

(Although this is an LWG issue, compiler change is necessary.)
```
#include <initializer_list>

template<class T>
class std::initializer_list<T*> {
private:
  void*               m_array_;
  decltype(sizeof(0)) m_len_;
};
```

But currently GCC (/w libstdc++) silently accepts it
(https://godbolt.org/z/q6TMo91Ef).

GCC should either directly detect such specializations (like MSVC and EDG) or
provide some more general mechanism like Clang's [[clang::no_specializations]].

Reply via email to