https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104944
Bug ID: 104944 Summary: incorrect alignas(void) accepted (with warning if templated) Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gccbugbjorn at fahller dot se Target Milestone: --- The erroneous code: struct alignas(void) S{}; Is accepted without any diagnostic with g++ (Compiler-Explorer-Build-gcc-98cd717fca9f21625b9c79c9231c2e909d1d93a3-binutils-2.36.1) 12.0.1 20220306 (experimental) https://godbolt.org/z/q7das4G1W With 'void' coming from a template, a confusing warning is issued: template <typename T> struct alignas(T) S {}; S<void> s; The message is: In instantiation of 'struct S<void>': <source>:4:9: required from here <source>:2:16: warning: invalid application of '__alignof__' to a void type [-Wpointer-arith] 2 | struct alignas(T) S {}; | ^ This is not entirely incorrect, but I believe most programmers would recognize that they have no `__alignof__` in their code, nor any pointer arithmetics.