Poniższy kod kompiluje grzywny z GCC:GCC akceptuje `constexpr struct {} s;` ale Clang je odrzuca. Kto jest poprawny?
constexpr struct {} s;
Ale Clang odrzuca je z powodu następującego błędu:
error: default initialization of an object of const type 'const struct (anonymous struct at …)' without a user-provided default constructor
mam przetestowane wszystkie wersje GCC i Clang, że udało mi się znaleźć w https://gcc.godbolt.org/. Każda wersja GCC akceptuje kod i każda wersja Klangu odrzuca go.
Zastanawiam się, który kompilator jest poprawny w tym przypadku?
Co standard mówi na ten temat?
Spróbuj clang-3.9? –
[CWG253] (http://wg21.link/CWG253). –
@ T.C. http://stackoverflow.com/questions/29683381/const-t-works-const-t-fails-when-t-is-a-non-pod#comment47503814_29683381 – Columbo