public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/110312] New: -Wcast-align=strict warning despite alignas @ 2023-06-19 14:40 f.heckenbach@fh-soft.de 2023-06-19 17:20 ` [Bug c++/110312] " pinskia at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: f.heckenbach@fh-soft.de @ 2023-06-19 14:40 UTC (permalink / raw) To: gcc-bugs 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.heckenbach@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? ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/110312] -Wcast-align=strict warning despite alignas 2023-06-19 14:40 [Bug c++/110312] New: -Wcast-align=strict warning despite alignas f.heckenbach@fh-soft.de @ 2023-06-19 17:20 ` pinskia at gcc dot gnu.org 2023-06-19 17:33 ` f.heckenbach@fh-soft.de 2023-06-20 8:10 ` rguenth at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-06-19 17:20 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110312 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- The decl has the increased alignment but the type does not in this case. So I think the warning is still correct. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/110312] -Wcast-align=strict warning despite alignas 2023-06-19 14:40 [Bug c++/110312] New: -Wcast-align=strict warning despite alignas f.heckenbach@fh-soft.de 2023-06-19 17:20 ` [Bug c++/110312] " pinskia at gcc dot gnu.org @ 2023-06-19 17:33 ` f.heckenbach@fh-soft.de 2023-06-20 8:10 ` rguenth at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: f.heckenbach@fh-soft.de @ 2023-06-19 17:33 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110312 --- Comment #2 from Frank Heckenbach <f.heckenbach@fh-soft.de> --- (In reply to Andrew Pinski from comment #1) > The decl has the increased alignment but the type does not in this case. > > So I think the warning is still correct. So there's no way around it other then disabling the warning, correct? ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/110312] -Wcast-align=strict warning despite alignas 2023-06-19 14:40 [Bug c++/110312] New: -Wcast-align=strict warning despite alignas f.heckenbach@fh-soft.de 2023-06-19 17:20 ` [Bug c++/110312] " pinskia at gcc dot gnu.org 2023-06-19 17:33 ` f.heckenbach@fh-soft.de @ 2023-06-20 8:10 ` rguenth at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: rguenth at gcc dot gnu.org @ 2023-06-20 8:10 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110312 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2023-06-20 Status|UNCONFIRMED |NEW Ever confirmed|0 |1 --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- I think the warning isn't useful at least, maybe it can be improved to not diagnose in the case where we can see an appropriately aligned decl (with some effort). ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-20 8:10 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-06-19 14:40 [Bug c++/110312] New: -Wcast-align=strict warning despite alignas f.heckenbach@fh-soft.de 2023-06-19 17:20 ` [Bug c++/110312] " pinskia at gcc dot gnu.org 2023-06-19 17:33 ` f.heckenbach@fh-soft.de 2023-06-20 8:10 ` rguenth at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).