Issue 1008: Bad constraint on attributes with tags

Authors: Joseph Myers
Date: 2025-03-11
Submitted against: C23
Status: Review

C23 6.7.3.2 (Structure and union specifiers) contains a constraint:

An attribute specifier sequence shall not appear in a struct-or-union specifier without a member declaration list, except in a declaration of the form:

struct-or-union attribute-specifier-sequence identifier ;

C23 6.7.3.4 (Tags) contains a stricter constraint:

A type specifier of the form

struct-or-union attribute-specifier-sequenceopt identifier

shall not contain an attribute specifier sequence.

The latter constraint does not make sense; if such an attribute specifier sequence is not allowed, why is this case in the syntax for struct-or-union-specifier at all?

The stated intent given in drafting notes in N2335 was:

struct [[something]] x; /* valid */
void f(struct [[something]] s); /* invalid */

However, both those cases go through the syntax for type-specifier, so both would be invalid with the constraints as written.

I think the latter constraint is in fact not needed at all because everything relevant is covered in the first quoted constraint.

Suggested correction

In C23 6.7.3.4 (Tags), remove the paragraph (including attached footnote):

A type specifier of the form

struct-or-union attribute-specifier-sequenceopt identifier

shall not contain an attribute specifier sequence.141)

141) As specified in 6.7.3.2, the type specifier can be followed by a ; or a member declaration list.


Comment from Issues list maintainer on 2025-09-01:

At the August 2025 (Brno) meeting of WG14, the suggested correction was accepted, subject to review at the next meeting.

Proposed correction

In C23 6.7.3.4 (Tags), remove the paragraph (including attached footnote):

A type specifier of the form

struct-or-union attribute-specifier-sequenceopt identifier

shall not contain an attribute specifier sequence.141)

141) As specified in 6.7.3.2, the type specifier can be followed by a ; or a member declaration list.