Consider the following c++ program: typedef struct { void f(); } X; int main() { } It is not rejected by the compiler when compiling with "-std=c++20 -pedantic-errors". The expected behaviour is that it should be rejected by section 9.2.3 paragraph 10 in the c++ 20 standard: " 10 An unnamed class with a typedef name for linkage purposes shall not (10.1) — declare any members other than non-static data members, member enumerations, or member classes, (10.2) — have any base classes or default member initializers, or (10.3) — contain a lambda-expression, and all member classes shall also satisfy these requirements (recursively). " Note that clang correctly does reject the program: https://godbolt.org/z/rTerza
I think this is a dup of bug 46589.
Well that's about the linkage of such entities, this is about whether they are ill-formed. The rule that makes this ill-formed was added by https://wg21.link/p1766r1 but was approved as a defect report against previous standards.
Maybe we should make this ill-formed for C++20, and a pedwarn otherwise, so existing code continues to compile using previous standards.
Sounds good to me! On Thu, 5 Aug 2021, 13:35 redi at gcc dot gnu.org, <gcc-bugzilla@gcc.gnu.org> wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97475 > > --- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- > Maybe we should make this ill-formed for C++20, and a pedwarn otherwise, so > existing code continues to compile using previous standards. > > -- > You are receiving this mail because: > You reported the bug.