https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110312
Bug ID: 110312 Summary: -Wcast-align=strict warning despite alignas Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: f.heckenb...@fh-soft.de Target Milestone: --- % cat test.cpp alignas (int) char a[sizeof (int)]; auto b = reinterpret_cast <int &> (a); % g++ -c -Wcast-align=strict test.cpp test.cpp:2:10: warning: cast from 'char (*)[4]' to 'int*' increases required alignment of target type [-Wcast-align] I'd kind of understand the warning if I was casting &a to int* because the alignas information might get lost when taking the address. So I tried casting a reference, but apparently (telling from the message), gcc implements this via a pointer cast anyway, so it doesn't help. FWIW, I got this when I tried to replace aligned_storage_t (which is deprecated in C++23 for reasons I don't really understand TBH) with a std::byte array as suggested. Does this mean that I simply can't use -Wcast-align=strict then?