<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 951</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="951"></A><H4>951.
  
Problems with <I>attribute-specifier</I>s
</H4>
<B>Section: </B>9.13&#160; [<A href="https://wg21.link/dcl.attr">dcl.attr</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD2
 &#160;&#160;&#160;

 <B>Submitter: </B>Sean Hunt
 &#160;&#160;&#160;

 <B>Date: </B>5 August, 2009<BR>


<P>[Voted into WP at March, 2010 meeting as document N3067.]</P>



<P>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:</P>

<UL>
<LI><P>In a <I>new-type-id</I> (7.6.2.8 [<A href="https://wg21.link/expr.new">expr.new</A>])</P></LI>

<LI><P>Preceding the <I>type-specifier-seq</I> in a <I>condition</I>
(8.5 [<A href="https://wg21.link/stmt.select">stmt.select</A>])</P></LI>

<LI><P>In a <I>for-init-statement</I> that is an <I>expression-statement</I>
(8.6 [<A href="https://wg21.link/stmt.iter">stmt.iter</A>])</P></LI>

<LI><P>Preceding the <I>type-specifier-seq</I> in a
<I>for-range-declaration</I> (8.6 [<A href="https://wg21.link/stmt.iter">stmt.iter</A>])</P></LI>

<LI><P>In a reference <I>ptr-operator</I> (9.3 [<A href="https://wg21.link/dcl.decl">dcl.decl</A>])</P></LI>

<LI><P>Preceding the <I>type-specifier-seq</I> in a <I>type-id</I>
(9.3.2 [<A href="https://wg21.link/dcl.name">dcl.name</A>])</P></LI>

<LI><P>Preceding the <I>decl-specifier-seq</I> in a
<I>parameter-declaration</I> (9.3.4.6 [<A href="https://wg21.link/dcl.fct">dcl.fct</A>])</P></LI>

<LI>
<P>In a <I>function-definition</I> (9.6 [<A href="https://wg21.link/dcl.fct.def">dcl.fct.def</A>]) at
any of the three locations where they might be expected:</P>

<UL>
<LI><P>preceding the <I>decl-specifier-seq</I>
</P></LI>

<LI><P>following the parameter list (paragraph 2 repeats the syntax
from 9.3.4.6 [<A href="https://wg21.link/dcl.fct">dcl.fct</A>] with the conspicuous omission of the
<I>attribute-specifier</I>)</P></LI>

<LI><P>preceding the <I>compound-statement</I> of the
<I>function-body</I> (this would introduce an ambiguity with the
<I>attribute-specifier</I> following the parameter list that would
need to be addressed)</P></LI>

</UL>

</LI>

<LI><P>Preceding the <I>decl-specifier-seq</I> of a
<I>member-declaration</I> (11.4 [<A href="https://wg21.link/class.mem">class.mem</A>])</P></LI>

<LI><P>Preceding the <I>compound-statement</I> of a <I>try-block</I>
or <I>handler</I> (Clause 14 [<A href="https://wg21.link/except">except</A>])</P></LI>

<LI><P>Preceding the <I>type-specifier-seq</I> of an
<I>exception-declaration</I> (Clause 14 [<A href="https://wg21.link/except">except</A>])</P></LI>

</UL>

<P>Another group of problems is the failure to specify to what
a given <I>attribute-specifier</I> appertains:</P>

<UL>
<LI><P>In a <I>condition</I> (8.5 [<A href="https://wg21.link/stmt.select">stmt.select</A>])</P></LI>

<LI><P>In a <I>for-range-declaration</I> (8.6.5 [<A href="https://wg21.link/stmt.ranged">stmt.ranged</A>])</P></LI>

<LI><P>In a <I>parameter-declaration</I> (9.3.4.6 [<A href="https://wg21.link/dcl.fct">dcl.fct</A>])</P></LI>

<LI><P>In a <I>conversion-type-id</I> (11.4.8.3 [<A href="https://wg21.link/class.conv.fct">class.conv.fct</A>])</P></LI>

</UL>

<P>There is also a problem in the specification of the interpretation of
an initial <I>attribute-specifier</I>.  9.3.4 [<A href="https://wg21.link/dcl.meaning#5">dcl.meaning</A>] paragraph 5
says,</P>

<BLOCKQUOTE>

In a declaration <I>attribute-specifier<SUB>opt</SUB></I> <TT>T</TT>
<I>attribute-specifier<SUB>opt</SUB></I> <TT>D</TT> where <TT>D</TT> is
an unadorned identifier the type of this identifier is
&#8220;<TT>T</TT>&#8221;. The first optional
<I>attribute-specifier</I> appertains to the entity being declared.

</BLOCKQUOTE>

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

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

<P>(See also <A HREF="968.html">issue 968</A>.)</P>

<P><B>Proposed resolution (February, 2010):</B></P>

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

<BR><BR>
</BODY>
</HTML>
