Title
Problems with attribute-specifiers
Status
cd2
Section
9.12 [dcl.attr]
Submitter
Sean Hunt

Created on 2009-08-05.00:00:00 last changed 171 months ago

Messages

Date: 2010-03-15.00:00:00

[Voted into WP at March, 2010 meeting as document N3067.]

Date: 2010-02-15.00:00:00

Proposed resolution (February, 2010):

See paper PL22.16/10-0023 = WG21 N3033.

Date: 2020-12-15.00:00:00

There are a number of problems with the treatment of attributes in the current draft. One issue is the failure to permit attributes to appear at various points in the grammar at which one might plausibly expect them:

  • In a new-type-id (7.6.2.8 [expr.new])

  • Preceding the type-specifier-seq in a condition (8.5 [stmt.select])

  • In a for-init-statement that is an expression-statement (8.6 [stmt.iter])

  • Preceding the type-specifier-seq in a for-range-declaration (8.6 [stmt.iter])

  • In a reference ptr-operator (9.3 [dcl.decl])

  • Preceding the type-specifier-seq in a type-id (9.3.2 [dcl.name])

  • Preceding the decl-specifier-seq in a parameter-declaration (9.3.4.6 [dcl.fct])

  • In a function-definition (9.5 [dcl.fct.def]) at any of the three locations where they might be expected:

    • preceding the decl-specifier-seq

    • following the parameter list (paragraph 2 repeats the syntax from 9.3.4.6 [dcl.fct] with the conspicuous omission of the attribute-specifier)

    • preceding the compound-statement of the function-body (this would introduce an ambiguity with the attribute-specifier following the parameter list that would need to be addressed)

  • Preceding the decl-specifier-seq of a member-declaration (11.4 [class.mem])

  • Preceding the compound-statement of a try-block or handler (Clause 14 [except])

  • Preceding the type-specifier-seq of an exception-declaration (Clause 14 [except])

Another group of problems is the failure to specify to what a given attribute-specifier appertains:

There is also a problem in the specification of the interpretation of an initial attribute-specifier. 9.3.4 [dcl.meaning] paragraph 5 says,

In a declaration attribute-specifieropt T attribute-specifieropt D where D is an unadorned identifier the type of this identifier is “T”. The first optional attribute-specifier appertains to the entity being declared.

This wording only covers the case where the declarator is a simple identifier. It leaves unspecified the meaning of the initial attribute-specifier with more complex declarators for pointers, references, functions, and arrays.

Finally, something needs to be said about the case where attribute-specifiers occur in both the initial position and following the declarator-id: is this permitted, and if so, under what constraints?

(See also issue 968.)

History
Date User Action Args
2010-03-29 00:00:00adminsetmessages: + msg2695
2010-03-29 00:00:00adminsetstatus: review -> cd2
2010-02-16 00:00:00adminsetmessages: + msg2539
2010-02-16 00:00:00adminsetstatus: drafting -> review
2009-11-08 00:00:00adminsetstatus: open -> drafting
2009-08-05 00:00:00admincreate