[Bug c/89132] missing -Wcast-align casting the address of a function to a more aligned pointer type
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jan 31 01:16:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89132
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Known to fail| |9.0
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Clang diagnoses both problems with just -Wcast-align (and apparently always
has):
u.c:2:16: warning: cast from 'int *' to 'long long *' increases required
alignment from 4 to 8 [-Wcast-align]
long long *p = (long long*)&i; // -Wcast-align (good)
^~~~~~~~~~~~~~
u.c:5:16: warning: cast from 'void (*)(void)' to 'long long *' increases
required alignment from 4 to 8 [-Wcast-align]
long long *q = (long long*)f; // missing -Wcast-align
^~~~~~~~~~~~~
2 warnings generated.
More information about the Gcc-bugs
mailing list