Why does Clang 12 refuse to initialize aggregates in the C++20 way?

This is a C++20 feature that allows aggregate initialization through the standard constructor syntax, rather than the typical braced-list initialization syntax. (Note that this only works if the parameters cannot be used in a valid call to a default or copy/move constructor. If they could, that would be called instead of performing aggregate initialization.)

According to the official C++ Support in Clang page, Clang does not yet support parenthesized initialization of aggregates (which is P0960R3 and P1975R0). This is as of Clang version 13.

A support matrix for C++20 features is also maintained on cppreference.com. This shows that support for P0960R3 is as follows:

  • GCC: supported as of version 10
  • MSVC: supported as of version 19.28
  • EDG eccp: supported as of version 5.1
  • Clang and Apple Clang: unsupported
  • Intel ICC: unsupported

Leave a Comment