https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81543
Bug ID: 81543
Summary: attribute may_alias on function and variable
declarations silently accepted
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
Attribute may_alias is documented among type attributes like so:
Accesses through pointers to types with this attribute are not subject to
type-based alias analysis, but are instead assumed to be able to alias any
other type of objects.
The attribute is not listed not among those that can be applied to functions or
variables, yet GCC also accepts it on declarations of those.
It doesn't seem meaningful to specify the attribute on variables (especially of
non-pointer types), and using on a function declaration seems dubious.
Either the attribute should be rejected in those two contexts, or its meaning
should be documented.
$ cat b.c && /ssd/build/gcc-80806/gcc/xgcc -B /ssd/build/gcc-80806/gcc -O2 -S
-Wall -Wextra -Wpedantic b.c
int var __attribute__ ((may_alias));
void __attribute__ ((may_alias)) foo (void);
$