https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88344
Bug ID: 88344
Summary: sole attribute specification in a class silently
accepted
Product: gcc
Version: 9.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: ---
The C++ front-end silently accepts sole attribute specifications within a class
that don't apply to any member of the class. The C front-end (and Clang and
ICC) issue a warning.
$ (set -x && cat t.c && gcc -S -Wall t.c && gcc -S -Wall -xc++ t.c)
+ cat t.c
struct B {
__attribute__ ((always_inline));
};
+ gcc -S -Wall t.c
t.c:2:3: warning: empty declaration
2 | __attribute__ ((always_inline));
| ^~~~~~~~~~~~~
+ gcc -S -Wall -xc++ t.c
The real code that this came up in actually looked more like this:
struct A
{
void* alloc (int); __attribute__ ((alloc_align (2)));
// ...
};
I.e., there was a spurious semicolon before the __attribute__ keyword. GCC
ended up swallowing and ignoring the attribute with no warning.