shafik added a comment. In D153857#4455480 <https://reviews.llvm.org/D153857#4455480>, @Fznamznon wrote:
>> MSVC rejects the first but accepts the second which I think is wrong but >> worth testing: >> >> alignof(struct B {}); >> sizeof(struct B{}); > > These don't have `new` so they are not affected by the patch ATM. > But why MSVC wrong? Operand of `alignof` is a `type-id` which is not > `defining-type-id` meaning it shouldn't be parsed as type definition. So, > `struct B{}` there is a reference to `struct B` with braced initializer, i.e. > object creation. That is not a `type-id`, right? On the opposite, `sizeof` > can accept either `type-id` or an expression, I guess this is why MSVC > accepts. new is special b/c it is has `new-initializer` after the `type-id` so that can be an initialization: https://eel.is/c++draft/expr.new#nt:new-expression in `sizeof` it is a definition which is not allowed and so it should be rejected. if you do: struct B{ int x; }; void f() { struct B{}; } That is a definition in `f`: https://godbolt.org/z/38eM6z17K Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153857/new/ https://reviews.llvm.org/D153857 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits