https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101265

--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot 
com> ---
On Tue, 29 Jun 2021, gcc at alanwu dot email via Gcc-bugs wrote:

>         [[maybe_unused]] int thisworks[1];

That attribute appertains to the declared entity.

>         int thisdoesnt[1] [[maybe_unused]];

Whereas that one appertains to the array type (that position after an 
array declarator can also be used for e.g. a pointer to an array, an array 
of arrays, etc., and an attribute there appertains to the specific array 
given by that declarator - not the declared entity as a whole).

It's not clear what it would mean to declare that some particular part of 
the type of an entity is possibly unused like that.  Appropriate places in 
a declaration are either at the start as in the first example, or after 
the identifier where an attribute specifier sequence appertains to the 
declared entity.

In general you need to be a lot more careful about the positioning of [[]] 
attributes than __attribute__.

Reply via email to