https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100698
Bug ID: 100698 Summary: Error when initializing a struct member of type char[N] with short string literal Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: iDingDong at outlook dot com Target Milestone: --- //--- struct [[maybe_unused]] A { char a[5]; }; int main() { A x = { .a = "Hey!" }; // OK A y = { .a = { 'H', 'i', '\0' } }; // OK A z = { .a = "Hi" }; // error: C99 designator 'a' outside aggregate initializer return 0; } //--- Compiled with > g++ -std=c++20 test.cpp This error is only triggered when attempting to initialize an array of char with a string literal of smaller size than the array was defined.