https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101859
Bug ID: 101859 Summary: Misleading error message in designated initializers Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hewillk at gmail dot com Target Milestone: --- struct Cat { const char* name; }; struct Zoo { Cat cat; }; int cat; Zoo zoo{.cat = cat}; Clang rejects it with: <source>:5:16: error: cannot initialize a member subobject of type 'const char *' with an lvalue of type 'int' Zoo zoo{.cat = cat}; ^~~ MSVC rejects it with: source>(5): error C2440: 'initializing': cannot convert from 'int' to 'const char *' However, GCC rejects it with: <source>:5:19: error: 'Cat' has no non-static data member named 'cat' 5 | Zoo zoo{.cat = cat}; | ^