<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>

    C++ Standard Core Language
    
      Active Issues
     </TITLE>
</HEAD>
<BODY>
<TABLE ALIGN="RIGHT" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD ALIGN="RIGHT">
      Document number:
     </TD>
<TD>
        &#160;PL22.16/09-0006 = WG21 N2816</TD>
</TR>
<TR>
<TD ALIGN="RIGHT">
      Date:
     </TD>
<TD>
      &#160;2009-02-08</TD>
</TR>
<TR>
<TD ALIGN="RIGHT">
      Project:
     </TD>
<TD>
      &#160;Programming Language C++
     </TD>
</TR>
<TR>
<TD ALIGN="RIGHT">
      Reference:
     </TD>
<TD>
      &#160;ISO/IEC IS 14882:2003
     </TD>
</TR>
<TR>
<TD ALIGN="RIGHT">
      Reply to:
     </TD>
<TD>
      &#160;William M. Miller
     </TD>
</TR>
<TR>
<TD></TD>
<TD>
      &#160;Edison Design Group, Inc.
     </TD>
</TR>
<TR>
<TD></TD>
<TD>
      &#160;<A HREF="mailto://wmm@edg.com">wmm@edg.com</A></TD>
</TR>
</TABLE><BR CLEAR="ALL"><BR><CENTER>
<H2>

     C++ Standard Core Language
     
       Active Issues,
      

     Revision
     61</H2>
</CENTER><BR><P>
      This document contains the C++ core language issues on which the
      Committee (J16 + WG21) has not yet acted, that is, issues
      with status
      "<A HREF="#Ready Status">Ready</A>,"
      "<A HREF="#Review Status">Review</A>,"
      "<A HREF="#Drafting Status">Drafting</A>," and
      "<A HREF="#Open Status">Open</A>."
     </P>
<P>
    This document is part of a group of related documents that
    together describe the issues that have been raised regarding the
    C++ Standard.  The other documents in the group are:
   </P>
<UL>
<LI><A HREF="cwg_closed.html">Closed Issues List</A>, which contains
      the issues which the Committee has decided are not defects
      in the International Standard, including a brief rationale
      explaining the reason for the decision.
     </LI>
<LI><A HREF="cwg_defects.html">Defect Reports List</A>, which contains
      the issues that have been categorized by the Committee as Defect
      Reports, along with their proposed resolutions.
     </LI>
<LI><A HREF="cwg_toc.html">Table of Contents</A>, which contains a
     summary listing of all issues in numerical order.
    </LI>
<LI><A HREF="cwg_index.html">Index by Section</A>, which contains a
     summary listing of all issues arranged in the order of the
     sections of the Standard with which they deal most directly.
    </LI>
<LI><A HREF="cwg_status.html">Index by Status</A>, which contains a
     summary listing of all issues grouped by status.
    </LI>
</UL>
<P>
    Section references in this document reflect the section numbering
    of document
    <A HREF="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2800.pdf">PL22.16/08-0310 = WG21 N2800</A>.
   </P>
<P>The purpose of these documents is to record the disposition of issues
that have come before the Core Language Working Group of the ANSI
(INCITS PL22.16) and ISO (WG21) C++ Standard Committee.</P>

<P>Some issues represent potential defects in the ISO/IEC IS 14882:2003
document and corrected defects in the earlier ISO/IEC 14882:1998 document;
others refer to text in the working draft for the next revision of the
C++ language, informally known as C++0x, and not to any Standard text.
Issues are not necessarily formal ISO Defect Reports (DRs).
While some issues will eventually be elevated to DR status, others
will be disposed of in other ways.  (See <A HREF="#Issue Status">Issue
Status</A> below.)</P>



<P>The most current public version of this document can be found at
<A HREF="http://www.open-std.org/jtc1/sc22/wg21">http://www.open-std.org/jtc1/sc22/wg21</A>. 
Requests for further information about these documents should include
the document number, reference ISO/IEC 14882:2003, and be
submitted to the InterNational Committee for Information Technology Standards
(INCITS),
1250&#160;Eye&#160;Street&#160;NW, Suite 200, Washington,&#160;DC&#160;20005,
USA.</P>

<P>Information regarding how to obtain a copy of the C++ Standard,
join the Standard Committee, or submit an issue
can be found in the C++ FAQ at
<A HREF="http://www.comeaucomputing.com/csc/faq.html">http://www.comeaucomputing.com/csc/faq.html</A>.
Public discussion of the C++ Standard and related issues occurs on
newsgroup <A HREF="news:comp.std.c++">comp.std.c++</A>.</P>

<BR>
<H3>Revision History</H3>

<UL>

<LI><B>Revision 61, 2009-02-08:</B> Provided a reference to a paper
containing a proposed resolution for issues <A HREF="
     cwg_active.html#695">695</A>
and <A HREF="
     cwg_active.html#699">699</A> and moved them to "review" status.
Added new issues
<A HREF="
     cwg_active.html#749">749</A>,
<A HREF="
     cwg_active.html#750">750</A>,
<A HREF="
     cwg_active.html#751">751</A>,
<A HREF="
     cwg_active.html#752">752</A>,
<A HREF="
     cwg_active.html#753">753</A>,
<A HREF="
     cwg_active.html#754">754</A>,
<A HREF="
     cwg_active.html#755">755</A>,
<A HREF="
     cwg_active.html#756">756</A>,
<A HREF="
     cwg_active.html#757">757</A>,
<A HREF="
     cwg_active.html#758">758</A>,
<A HREF="
     cwg_active.html#759">759</A>,
<A HREF="
     cwg_active.html#760">760</A>,
<A HREF="
     cwg_active.html#761">761</A>,
<A HREF="
     cwg_active.html#762">762</A>,
<A HREF="
     cwg_active.html#763">763</A>,
<A HREF="
     cwg_active.html#764">764</A>,
<A HREF="
     cwg_active.html#765">765</A>, and
<A HREF="
     cwg_active.html#766">766</A>.
</LI>

<LI><B>Revision 60, 2008-12-09:</B> Revised the resolution of
<A HREF="
     cwg_active.html#653">issue 653</A> and moved to "review" status.
Added new issues
<A HREF="
     cwg_active.html#724">724</A>,
<A HREF="
     cwg_active.html#725">725</A>,
<A HREF="
     cwg_active.html#726">726</A>,
<A HREF="
     cwg_active.html#727">727</A>,
<A HREF="
     cwg_active.html#728">728</A>,
<A HREF="
     cwg_active.html#729">729</A>,
<A HREF="
     cwg_active.html#730">730</A>,
<A HREF="
     cwg_active.html#731">731</A>,
<A HREF="
     cwg_active.html#732">732</A>,
<A HREF="
     cwg_active.html#733">733</A>,
<A HREF="
     cwg_active.html#734">734</A>,
<A HREF="
     cwg_active.html#735">735</A>,
<A HREF="
     cwg_active.html#736">736</A>,
<A HREF="
     cwg_active.html#737">737</A>,
<A HREF="
     cwg_active.html#738">738</A>,
<A HREF="
     cwg_active.html#739">739</A>,
<A HREF="
     cwg_active.html#740">740</A>,
<A HREF="
     cwg_active.html#741">741</A>,
<A HREF="
     cwg_active.html#742">742</A>,
<A HREF="
     cwg_active.html#743">743</A>,
<A HREF="
     cwg_active.html#744">744</A>,
<A HREF="
     cwg_active.html#745">745</A>,
<A HREF="
     cwg_active.html#746">746</A>,
<A HREF="
     cwg_active.html#747">747</A>, and
<A HREF="
     cwg_active.html#748">748</A>.
</LI>

<LI><B>Revision 59, 2008-10-05:</B> Reflected deliberations from the
San Francisco (September, 2008) meeting. Placed all issues with
"WP" status and newly-approved "DR" issues into "CD1" status, to
reflect advancing the Committee Draft for balloting.  Added new
proposed resolutions to issues <A HREF="
     cwg_active.html#696">696</A>,
<A HREF="
     cwg_active.html#704">704</A>, and <A HREF="
     cwg_active.html#705">705</A>
and moved them to "review" status. Changed
<A HREF="
     cwg_closed.html#265">issue 265</A> to "dup" status in favor of
<A HREF="
     cwg_defects.html#353">issue 353</A>, which was approved in 2003.
Added new issues
<A HREF="
     cwg_active.html#710">710</A>,
<A HREF="
     cwg_active.html#711">711</A>,
<A HREF="
     cwg_active.html#712">712</A>,
<A HREF="
     cwg_active.html#713">713</A>,
<A HREF="
     cwg_active.html#714">714</A>,
<A HREF="
     cwg_active.html#715">715</A>,
<A HREF="
     cwg_active.html#716">716</A>,
<A HREF="
     cwg_active.html#717">717</A>,
<A HREF="
     cwg_active.html#718">718</A>,
<A HREF="
     cwg_active.html#719">719</A>,
<A HREF="
     cwg_active.html#720">720</A>,
<A HREF="
     cwg_active.html#721">721</A>,
<A HREF="
     cwg_active.html#722">722</A>, and
<A HREF="
     cwg_active.html#723">723</A>.
</LI>

<LI><B>Revision 58, 2008-08-25:</B> Fixed some incorrect section
references.  Fixed the title of <A HREF="
     cwg_active.html#692">issue 692</A>.
Changed the status of <A HREF="
     cwg_defects.html#603">issue 603</A> to "WP",
as the paper that resolved it was approved in April, 2007.  Moved
<A HREF="
     cwg_active.html#657">issue 657</A> back to "review" status and
added proposed wording. Added discussion to issues
<A HREF="
     cwg_active.html#693">693</A> and <A HREF="
     cwg_active.html#697">697</A>.
Added or revised resolutions for issues
<A HREF="
     cwg_defects.html#606">606</A>,
<A HREF="
     cwg_defects.html#614">614</A>,
<A HREF="
     cwg_active.html#652">652</A>,
<A HREF="
     cwg_active.html#685">685</A>, and
<A HREF="
     cwg_active.html#694">694</A> and moved them to "review" status.
Added new issues
<A HREF="
     cwg_active.html#704">704</A>,
<A HREF="
     cwg_active.html#705">705</A>,
<A HREF="
     cwg_closed.html#706">706</A>,
<A HREF="
     cwg_active.html#707">707</A>,
<A HREF="
     cwg_active.html#708">708</A>, and
<A HREF="
     cwg_active.html#709">709</A>.
</LI>

<LI><B>Revision 57, 2008-07-27:</B>  Updated the status of issues
<A HREF="
     cwg_defects.html#222">222</A>, <A HREF="
     cwg_defects.html#309">309</A>, and
<A HREF="
     cwg_defects.html#632">632</A> to reflect actions at the June, 2008
meeting that were inadvertently omitted in the preceding revision.
Added proposed wording for
<A HREF="
     cwg_defects.html#683">issue 683</A> and moved it to "review" status.
Added new issues
<A HREF="
     cwg_active.html#697">697</A>,
<A HREF="
     cwg_active.html#698">698</A>,
<A HREF="
     cwg_active.html#699">699</A>,
<A HREF="
     cwg_active.html#700">700</A>,
<A HREF="
     cwg_active.html#701">701</A>,
<A HREF="
     cwg_active.html#702">702</A>, and
<A HREF="
     cwg_active.html#703">703</A>.
</LI>

<LI><B>Revision 56, 2008-06-29:</B> Reflected deliberations from the
Sophia Antipolis (June, 2008) meeting.  Added discussion to issues
<A HREF="
     cwg_active.html#507">507</A> and
<A HREF="
     cwg_active.html#527">527</A>. Added proposed resolution for
<A HREF="
     cwg_active.html#653">issue 653</A>.  Added new issues
<A HREF="
     cwg_active.html#695">695</A> and <A HREF="
     cwg_active.html#696">696</A>.
</LI>

<LI><B>Revision 55, 2008-05-18:</B> Added proposed resolutions for
issues
<A HREF="
     cwg_defects.html#220">220</A>,
<A HREF="
     cwg_active.html#257">257</A>,
<A HREF="
     cwg_active.html#292">292</A>,
<A HREF="
     cwg_active.html#341">341</A>,
<A HREF="
     cwg_active.html#539">539</A>,
<A HREF="
     cwg_active.html#554">554</A>,
<A HREF="
     cwg_active.html#570">570</A>,
<A HREF="
     cwg_active.html#571">571</A>,
<A HREF="
     cwg_active.html#576">576</A>,
<A HREF="
     cwg_active.html#597">597</A>,
<A HREF="
     cwg_active.html#621">621</A>,
<A HREF="
     cwg_defects.html#624">624</A>,
<A HREF="
     cwg_active.html#626">626</A>,
<A HREF="
     cwg_active.html#633">633</A>,
<A HREF="
     cwg_defects.html#634">634</A>,
<A HREF="
     cwg_defects.html#639">639</A>, and
<A HREF="
     cwg_active.html#642">642</A>,
and moved them to "review" status.
Moved <A HREF="
     cwg_closed.html#155">issue 155</A> to "dup" status in
favor of <A HREF="
     cwg_defects.html#632">issue 632</A>, which was changed
to "review" status in light of its connection with the
initializer-list proposal.  Moved issues <A HREF="
     cwg_defects.html#530">530</A>
and <A HREF="
     cwg_defects.html#551">551</A>
to "WP" status because they were resolved by the constexpr proposal.
Moved <A HREF="
     cwg_closed.html#646">issue 646</A> to "review" status because
it appears to be "NAD".  Changed <A HREF="
     cwg_active.html#240">issue 240</A>
to "review" status (from "ready") in light of input from WG14 regarding
a similar issue.  Added new issues
<A HREF="
     cwg_active.html#685">685</A>,
<A HREF="
     cwg_defects.html#686">686</A>,
<A HREF="
     cwg_active.html#687">687</A>,
<A HREF="
     cwg_defects.html#688">688</A>,
<A HREF="
     cwg_active.html#689">689</A>,
<A HREF="
     cwg_active.html#690">690</A>,
<A HREF="
     cwg_active.html#691">691</A>,
<A HREF="
     cwg_active.html#692">692</A>,
<A HREF="
     cwg_active.html#693">693</A>, and
<A HREF="
     cwg_active.html#694">694</A>.
</LI>

<LI><B>Revision 54, 2008-03-17:</B> Reflected deliberations from the
Bellevue (February, 2008) meeting.  Restructured references inside
&#8220;definitions&#8221; sections (1.3
 [intro.defs],
17.3
 [definitions]) because the individual definitions are not
sections.  Returned <A HREF="
     cwg_closed.html#646">issue 646</A> to "open"
status (it was previously erroneously in "drafting" status).  Moved
issues <A HREF="
     cwg_active.html#347">347</A>, <A HREF="
     cwg_active.html#512">512</A>,
and <A HREF="
     cwg_active.html#236">236</A> to "review" status with a
recommendation to close them as "NAD."  Changed issues <A HREF="
     cwg_defects.html#220">220</A> and <A HREF="
     cwg_defects.html#256">256</A> back to "open"
status  and
annotated them to indicate that they have been accepted by EWG and
referred to CWG for action for C++0x.  Changed issues <A HREF="
     cwg_active.html#6">6</A> and <A HREF="
     cwg_active.html#150">150</A> back to "open"
status  and
annotated them to indicate that they have been accepted by EWG and
referred to CWG for action, but not for C++0x. Closed issues
<A HREF="
     cwg_closed.html#107">107</A>,
<A HREF="
     cwg_closed.html#168">168</A>,
<A HREF="
     cwg_closed.html#229">229</A>,
<A HREF="
     cwg_closed.html#294">294</A>, and
<A HREF="
     cwg_closed.html#359">359</A> as "NAD" to reflect the recommendation
of EWG.  Added new issues
<A HREF="
     cwg_active.html#673">673</A>,
<A HREF="
     cwg_active.html#674">674</A>,
<A HREF="
     cwg_active.html#675">675</A>,
<A HREF="
     cwg_active.html#676">676</A>,
<A HREF="
     cwg_defects.html#677">677</A>,
<A HREF="
     cwg_active.html#678">678</A>,
<A HREF="
     cwg_defects.html#679">679</A>,
<A HREF="
     cwg_active.html#680">680</A>,
<A HREF="
     cwg_defects.html#681">681</A>,
<A HREF="
     cwg_active.html#682">682</A>,
<A HREF="
     cwg_defects.html#683">683</A>, and
<A HREF="
     cwg_defects.html#684">684</A>.
</LI>

<LI><B>Revision 53, 2008-02-03:</B>
Updated the proposed resolutions for issues <A HREF="
     cwg_defects.html#288">288</A>
and <A HREF="
     cwg_active.html#342">342</A>.  Updated the status of issues
<A HREF="
     cwg_defects.html#199">199</A> and <A HREF="
     cwg_defects.html#430">430</A> to reflect
actions at the Oxford (April, 2007) meeting.
Added proposed resolutions and
changed the status to "review" for issues
<A HREF="
     cwg_defects.html#28">28</A>,
<A HREF="
     cwg_active.html#111">111</A>,
<A HREF="
     cwg_defects.html#118">118</A>,
<A HREF="
     cwg_defects.html#141">141</A>,
<A HREF="
     cwg_active.html#240">240</A>,
<A HREF="
     cwg_defects.html#276">276</A>,
<A HREF="
     cwg_defects.html#309">309</A>,
<A HREF="
     cwg_active.html#355">355</A>,
<A HREF="
     cwg_active.html#373">373</A>,
<A HREF="
     cwg_active.html#378">378</A>,
<A HREF="
     cwg_active.html#462">462</A>,
<A HREF="
     cwg_defects.html#485">485</A>,
<A HREF="
     cwg_active.html#535">535</A>,
<A HREF="
     cwg_active.html#574">574</A>,
<A HREF="
     cwg_active.html#601">601</A>,
<A HREF="
     cwg_active.html#608">608</A>,
<A HREF="
     cwg_active.html#641">641</A>,
<A HREF="
     cwg_active.html#645">645</A>, and
<A HREF="
     cwg_defects.html#651">651</A>.
Added new issues
<A HREF="
     cwg_active.html#667">667</A>,
<A HREF="
     cwg_active.html#668">668</A>,
<A HREF="
     cwg_closed.html#669">669</A>,
<A HREF="
     cwg_active.html#670">670</A>,
<A HREF="
     cwg_defects.html#671">671</A>, and
<A HREF="
     cwg_active.html#672">672</A>.
</LI>

<LI><B>Revision 52, 2007-12-09:</B>
Updated the status of issues <A HREF="
     cwg_defects.html#568">568</A> and
<A HREF="
     cwg_defects.html#620">620</A> to reflect actions at the Toronto
(July, 2007) meeting. Fixed a typographical error in the example for
<A HREF="
     cwg_defects.html#606">issue 606</A>.
Added new issues
<A HREF="
     cwg_defects.html#654">654</A>,
<A HREF="
     cwg_active.html#655">655</A>,
<A HREF="
     cwg_active.html#656">656</A>,
<A HREF="
     cwg_active.html#657">657</A>,
<A HREF="
     cwg_active.html#658">658</A>,
<A HREF="
     cwg_defects.html#659">659</A>,
<A HREF="
     cwg_defects.html#660">660</A>,
<A HREF="
     cwg_defects.html#661">661</A>,
<A HREF="
     cwg_closed.html#662">662</A>,
<A HREF="
     cwg_defects.html#663">663</A>,
<A HREF="
     cwg_active.html#664">664</A>,
<A HREF="
     cwg_active.html#665">665</A>, and
<A HREF="
     cwg_defects.html#666">666</A>.
</LI>

<LI><B>Revision 51, 2007-10-09:</B> Reflected deliberations from the Kona
(October, 2007) meeting.  Added new issues
<A HREF="
     cwg_active.html#652">652</A> and <A HREF="
     cwg_active.html#653">653</A>.
</LI>

<LI><B>Revision 50, 2007-09-09:</B> Updated section reference numbers to use
the numbering of the most recent working draft and added text identifying
the document number of that draft at the beginning of each issues
list document.  Updated <A HREF="
     cwg_active.html#475">issue 475</A>
with discussion regarding the point at which
<TT>std::uncaught_exception()</TT> becomes <TT>false</TT>.  Added new issues
<A HREF="
     cwg_active.html#642">642</A>,
<A HREF="
     cwg_closed.html#643">643</A>,
<A HREF="
     cwg_defects.html#644">644</A>,
<A HREF="
     cwg_active.html#645">645</A>,
<A HREF="
     cwg_closed.html#646">646</A>,
<A HREF="
     cwg_defects.html#647">647</A>,
<A HREF="
     cwg_defects.html#648">648</A>,
<A HREF="
     cwg_defects.html#649">649</A>,
<A HREF="
     cwg_active.html#650">650</A>, and
<A HREF="
     cwg_defects.html#651">651</A>.
</LI>

<LI><B>Revision 49, 2007-08-05:</B> Reflected deliberations from the
Toronto (July, 2007) meeting.  Added additional discussion to issues
<A HREF="
     cwg_active.html#219">219</A> and <A HREF="
     cwg_defects.html#339">339</A>.
Added new issues
<A HREF="
     cwg_defects.html#637">637</A>,
<A HREF="
     cwg_active.html#638">638</A>,
<A HREF="
     cwg_defects.html#639">639</A>,
<A HREF="
     cwg_active.html#640">640</A>, and
<A HREF="
     cwg_active.html#641">641</A>.
</LI>

<LI><B>Revision 48, 2007-06-24:</B> Added new issues
<A HREF="
     cwg_defects.html#632">632</A>,
<A HREF="
     cwg_active.html#633">633</A>,
<A HREF="
     cwg_defects.html#634">634</A>,
<A HREF="
     cwg_closed.html#635">635</A>, and
<A HREF="
     cwg_active.html#636">636</A>.
</LI>

<LI><B>Revision 47, 2007-05-06:</B> Reflected deliberations from the
Oxford (April, 2007) meeting.
Added new issues
<A HREF="
     cwg_active.html#626">626</A>,
<A HREF="
     cwg_closed.html#627">627</A>,
<A HREF="
     cwg_active.html#628">628</A>,
<A HREF="
     cwg_defects.html#629">629</A>,
<A HREF="
     cwg_active.html#630">630</A>, and
<A HREF="
     cwg_active.html#631">631</A>.
</LI>

<LI><B>Revision 46, 2007-03-11:</B> Added proposed wording to
<A HREF="
     cwg_active.html#495">issue 495</A> and moved it to
&#8220;review&#8221; status.  Added new issues
<A HREF="
     cwg_active.html#612">612</A>,
<A HREF="
     cwg_defects.html#613">613</A>,
<A HREF="
     cwg_defects.html#614">614</A>,
<A HREF="
     cwg_active.html#615">615</A>,
<A HREF="
     cwg_active.html#616">616</A>,
<A HREF="
     cwg_active.html#617">617</A>,
<A HREF="
     cwg_active.html#618">618</A>,
<A HREF="
     cwg_active.html#619">619</A>,
<A HREF="
     cwg_defects.html#620">620</A>,
<A HREF="
     cwg_active.html#621">621</A>,
<A HREF="
     cwg_closed.html#622">622</A>,
<A HREF="
     cwg_closed.html#623">623</A>,
<A HREF="
     cwg_defects.html#624">624</A>, and
<A HREF="
     cwg_active.html#625">625</A>.
</LI>

<LI><B>Revision 45, 2007-01-14:</B> Changed the status of
<A HREF="
     cwg_defects.html#78">issue 78</A> from TC1 to WP.
Added new issues
<A HREF="
     cwg_defects.html#603">603</A>,
<A HREF="
     cwg_active.html#604">604</A>,
<A HREF="
     cwg_active.html#605">605</A>,
<A HREF="
     cwg_defects.html#606">606</A>,
<A HREF="
     cwg_active.html#607">607</A>,
<A HREF="
     cwg_active.html#608">608</A>,
<A HREF="
     cwg_active.html#609">609</A>,
<A HREF="
     cwg_closed.html#610">610</A>, and
<A HREF="
     cwg_active.html#611">611</A>.
</LI>

<LI><B>Revision 44, 2006-11-05:</B> Reflected deliberations from the
Portland (October, 2006) meeting.  Added proposed wording for issues
<A HREF="
     cwg_defects.html#288">288</A>,
<A HREF="
     cwg_active.html#342">342</A>, and
<A HREF="
     cwg_active.html#572">572</A>, and moved them to &#8220;review&#8221;
status.  Added new issues
<A HREF="
     cwg_active.html#596">596</A>,
<A HREF="
     cwg_active.html#597">597</A>,
<A HREF="
     cwg_active.html#598">598</A>,
<A HREF="
     cwg_active.html#599">599</A>,
<A HREF="
     cwg_active.html#600">600</A>,
<A HREF="
     cwg_active.html#601">601</A>, and
<A HREF="
     cwg_active.html#602">602</A>.
</LI>

<LI><B>Revision 43, 2006-09-09:</B> Updated issues
<A HREF="
     cwg_defects.html#218">218</A>,
<A HREF="
     cwg_defects.html#357">357</A>, and
<A HREF="
     cwg_defects.html#537">537</A> with additional discussion and proposed
resolutions and moved them to &#8220;review&#8221; status; added issues
<A HREF="
     cwg_active.html#589">589</A>,
<A HREF="
     cwg_active.html#590">590</A>,
<A HREF="
     cwg_active.html#591">591</A>,
<A HREF="
     cwg_defects.html#592">592</A>,
<A HREF="
     cwg_closed.html#593">593</A>,
<A HREF="
     cwg_defects.html#594">594</A>, and
<A HREF="
     cwg_active.html#595">595</A>.
</LI>

<LI><B>Revision 42, 2006-06-23:</B> Updated issues
<A HREF="
     cwg_active.html#408">408</A> and <A HREF="
     cwg_active.html#561">561</A> with
additional discussion; added a reference to a paper on the topic to
<A HREF="
     cwg_closed.html#567">issue 567</A>; and added issues
<A HREF="
     cwg_active.html#578">578</A>,
<A HREF="
     cwg_active.html#579">579</A>,
<A HREF="
     cwg_active.html#580">580</A>,
<A HREF="
     cwg_active.html#581">581</A>,
<A HREF="
     cwg_defects.html#582">582</A>,
<A HREF="
     cwg_active.html#583">583</A>,
<A HREF="
     cwg_closed.html#584">584</A>,
<A HREF="
     cwg_closed.html#585">585</A>,
<A HREF="
     cwg_active.html#586">586</A>,
<A HREF="
     cwg_active.html#587">587</A>, and
<A HREF="
     cwg_active.html#588">588</A>.
</LI>

<LI><B>Revision 41, 2006-04-22:</B> Reflected deliberations from the
Berlin (April, 2006) meeting.  Added issues
<A HREF="
     cwg_active.html#562">562</A>,
<A HREF="
     cwg_active.html#563">563</A>,
<A HREF="
     cwg_active.html#564">564</A>,
<A HREF="
     cwg_active.html#565">565</A>,
<A HREF="
     cwg_closed.html#566">566</A>,
<A HREF="
     cwg_closed.html#567">567</A>,
<A HREF="
     cwg_defects.html#568">568</A>,
<A HREF="
     cwg_active.html#569">569</A>,
<A HREF="
     cwg_active.html#570">570</A>,
<A HREF="
     cwg_active.html#571">571</A>,
<A HREF="
     cwg_active.html#572">572</A>,
<A HREF="
     cwg_active.html#573">573</A>,
<A HREF="
     cwg_active.html#574">574</A>,
<A HREF="
     cwg_active.html#575">575</A>,
<A HREF="
     cwg_active.html#576">576</A>, and
<A HREF="
     cwg_active.html#577">577</A>.
</LI>

<LI><B>Revision 40, 2006-02-24:</B> Updated
<A HREF="
     cwg_defects.html#540">issue 540</A> to refer to paper
J16/06-0022 = WG21 N1952 for its resolution.  Updated
<A HREF="
     cwg_active.html#453">issue 453</A> to note the need for additional
drafting.  Reopened <A HREF="
     cwg_active.html#504">issue 504</A> and broadened
its scope to include object declarations as well.  Updated
<A HREF="
     cwg_active.html#150">issue 150</A> (in &#8220;extension&#8221; status)
with additional commentary.
Added issues
<A HREF="
     cwg_closed.html#552">552</A>,
<A HREF="
     cwg_closed.html#553">553</A>,
<A HREF="
     cwg_active.html#554">554</A>,
<A HREF="
     cwg_active.html#555">555</A>,
<A HREF="
     cwg_active.html#556">556</A>,
<A HREF="
     cwg_defects.html#557">557</A>,
<A HREF="
     cwg_defects.html#558">558</A>,
<A HREF="
     cwg_defects.html#559">559</A>,
<A HREF="
     cwg_active.html#560">560</A>, and
<A HREF="
     cwg_active.html#561">561</A>.
</LI>

<LI><B>Revision 39, 2005-12-16:</B> Updated
<A HREF="
     cwg_defects.html#488">issue 488</A> with additional discussion.
Added issues
<A HREF="
     cwg_defects.html#538">538</A>,
<A HREF="
     cwg_active.html#539">539</A>,
<A HREF="
     cwg_defects.html#540">540</A>,
<A HREF="
     cwg_active.html#541">541</A>,
<A HREF="
     cwg_active.html#542">542</A>,
<A HREF="
     cwg_defects.html#543">543</A>,
<A HREF="
     cwg_closed.html#544">544</A>,
<A HREF="
     cwg_active.html#545">545</A>,
<A HREF="
     cwg_active.html#546">546</A>,
<A HREF="
     cwg_active.html#547">547</A>,
<A HREF="
     cwg_closed.html#548">548</A>,
<A HREF="
     cwg_active.html#549">549</A>,
<A HREF="
     cwg_active.html#550">550</A>, and
<A HREF="
     cwg_defects.html#551">551</A>.
</LI>

<LI><B>Revision 38, 2005-10-22:</B> Reflected deliberations from the
Mont Tremblant (October, 2005) meeting.  Added isues
<A HREF="
     cwg_defects.html#530">530</A>,
<A HREF="
     cwg_active.html#531">531</A>,
<A HREF="
     cwg_active.html#532">532</A>,
<A HREF="
     cwg_closed.html#533">533</A>,
<A HREF="
     cwg_defects.html#534">534</A>,
<A HREF="
     cwg_active.html#535">535</A>,
<A HREF="
     cwg_active.html#536">536</A>, and
<A HREF="
     cwg_defects.html#537">537</A>.
</LI>

<LI><B>Revision 37, 2005-08-27:</B> Added issues
<A HREF="
     cwg_active.html#523">523</A>,
<A HREF="
     cwg_defects.html#524">524</A>,
<A HREF="
     cwg_defects.html#525">525</A>,
<A HREF="
     cwg_defects.html#526">526</A>,
<A HREF="
     cwg_active.html#527">527</A>,
<A HREF="
     cwg_active.html#528">528</A>, and
<A HREF="
     cwg_active.html#529">529</A>.
</LI>

<LI><B>Revision 36, 2005-06-27:</B> Reopened <A HREF="
     cwg_defects.html#484">issue 484</A> for additional discussion.
Added issues
<A HREF="
     cwg_defects.html#517">517</A>,
<A HREF="
     cwg_defects.html#518">518</A>,
<A HREF="
     cwg_defects.html#519">519</A>,
<A HREF="
     cwg_defects.html#520">520</A>,
<A HREF="
     cwg_defects.html#521">521</A>, and
<A HREF="
     cwg_defects.html#522">522</A>.
</LI>

<LI><B>Revision 35, 2005-05-01:</B> Reflected deliberations from
the Lillehammer (April, 2005) meeting.  Updated issues
<A HREF="
     cwg_active.html#189">189</A> and <A HREF="
     cwg_active.html#459">459</A> with additional
discussion.  Added new issues
<A HREF="
     cwg_active.html#504">504</A>,
<A HREF="
     cwg_defects.html#505">505</A>,
<A HREF="
     cwg_defects.html#506">506</A>,
<A HREF="
     cwg_active.html#507">507</A>,
<A HREF="
     cwg_active.html#508">508</A>,
<A HREF="
     cwg_defects.html#509">509</A>,
<A HREF="
     cwg_defects.html#510">510</A>,
<A HREF="
     cwg_active.html#511">511</A>,
<A HREF="
     cwg_active.html#512">512</A>,
<A HREF="
     cwg_defects.html#513">513</A>,
<A HREF="
     cwg_defects.html#514">514</A>,
<A HREF="
     cwg_defects.html#515">515</A>, and
<A HREF="
     cwg_defects.html#516">516</A>.
</LI>

<LI><B>Revision 34: 2005-03-06:</B> Closed <A HREF="
     cwg_closed.html#471">issue 471</A> as NAD; updated issues
<A HREF="
     cwg_defects.html#58">58</A>,
<A HREF="
     cwg_active.html#232">232</A>,
<A HREF="
     cwg_defects.html#339">339</A>,
<A HREF="
     cwg_active.html#407">407</A>, and
<A HREF="
     cwg_defects.html#494">494</A>
with additional discussion; and added new issues
<A HREF="
     cwg_active.html#498">498</A>,
<A HREF="
     cwg_active.html#499">499</A>,
<A HREF="
     cwg_defects.html#500">500</A>,
<A HREF="
     cwg_closed.html#501">501</A>,
<A HREF="
     cwg_active.html#502">502</A>, and
<A HREF="
     cwg_active.html#503">503</A>.
</LI>

<LI><B>Revision 33: 2005-01-14:</B> Updated <A HREF="
     cwg_active.html#36">issue 36</A> with additional discussion.  Added new
issues
<A HREF="
     cwg_defects.html#485">485</A>,
<A HREF="
     cwg_defects.html#486">486</A>,
<A HREF="
     cwg_closed.html#487">487</A>,
<A HREF="
     cwg_defects.html#488">488</A>,
<A HREF="
     cwg_closed.html#489">489</A>,
<A HREF="
     cwg_active.html#490">490</A>,
<A HREF="
     cwg_defects.html#491">491</A>,
<A HREF="
     cwg_defects.html#492">492</A>,
<A HREF="
     cwg_active.html#493">493</A>,
<A HREF="
     cwg_defects.html#494">494</A>,
<A HREF="
     cwg_active.html#495">495</A>,
<A HREF="
     cwg_active.html#496">496</A>, and
<A HREF="
     cwg_defects.html#497">497</A>.
</LI>

<LI><B>Revision 32: 2004-11-07:</B> Reflected deliberations from
the Redmond (October, 2004) meeting.  Added new issues
<A HREF="
     cwg_active.html#475">475</A>,
<A HREF="
     cwg_active.html#476">476</A>,
<A HREF="
     cwg_defects.html#477">477</A>,
<A HREF="
     cwg_closed.html#478">478</A>,
<A HREF="
     cwg_defects.html#479">479</A>,
<A HREF="
     cwg_defects.html#480">480</A>,
<A HREF="
     cwg_active.html#481">481</A>,
<A HREF="
     cwg_active.html#482">482</A>,
<A HREF="
     cwg_active.html#483">483</A>, and
<A HREF="
     cwg_defects.html#484">484</A>.
</LI>

<LI>
<B>Revision 31: 2004-09-10:</B> Updated <A HREF="
     cwg_active.html#268">issue 268</A> with comments from WG14; added comments and changed
the status of <A HREF="
     cwg_defects.html#451">issue 451</A> back to
&#8220;open&#8221;; added discussion to issues
<A HREF="
     cwg_closed.html#334">334</A>,
<A HREF="
     cwg_active.html#341">341</A>,
<A HREF="
     cwg_defects.html#385">385</A>,
<A HREF="
     cwg_active.html#399">399</A>, and
<A HREF="
     cwg_defects.html#430">430</A>;
and added new issues
<A HREF="
     cwg_defects.html#470">470</A>,
<A HREF="
     cwg_closed.html#471">471</A>,
<A HREF="
     cwg_active.html#472">472</A>,
<A HREF="
     cwg_active.html#473">473</A>, and
<A HREF="
     cwg_defects.html#474">474</A>.
</LI>

<LI>
<B>Revision 30: 2004-04-09:</B> Reflected deliberations from the
Sydney (March, 2004) meeting.  Added issues 461-469, updated issues
<A HREF="
     cwg_defects.html#39">39</A>,
<A HREF="
     cwg_defects.html#86">86</A>,
<A HREF="
     cwg_active.html#257">257</A>,
<A HREF="
     cwg_defects.html#291">291</A>,
<A HREF="
     cwg_defects.html#391">391</A>,
<A HREF="
     cwg_defects.html#389">389</A>,
<A HREF="
     cwg_closed.html#435">435</A>,
<A HREF="
     cwg_defects.html#436">436</A>,
<A HREF="
     cwg_defects.html#437">437</A>,
<A HREF="
     cwg_defects.html#439">439</A>,
<A HREF="
     cwg_defects.html#441">441</A>,
<A HREF="
     cwg_defects.html#442">442</A>,
<A HREF="
     cwg_defects.html#446">446</A>,
<A HREF="
     cwg_defects.html#450">450</A>,
<A HREF="
     cwg_active.html#453">453</A>,
and
<A HREF="
     cwg_active.html#458">458</A>.
</LI>

<LI>
<B>Revision 29: 2004-02-13:</B> Added issues 441-460, updated issues
<A HREF="
     cwg_defects.html#39">39</A>,
<A HREF="
     cwg_defects.html#291">291</A>,
<A HREF="
     cwg_defects.html#306">306</A>,
<A HREF="
     cwg_defects.html#319">319</A>,
<A HREF="
     cwg_defects.html#389">389</A>,
<A HREF="
     cwg_defects.html#394">394</A>,
<A HREF="
     cwg_defects.html#413">413</A>,
and
<A HREF="
     cwg_defects.html#417">417</A>.
</LI>

<LI>
<B>Revision 28: 2003-11-15:</B> Reflected deliberations from the
Kona (October, 2003) meeting.  Added issues 435-438.
</LI>

<LI>
<B>Revision 27: 2003-09-19:</B> Added new issues 412-434, updated
<A HREF="
     cwg_defects.html#54">issues 54</A>,
<A HREF="
     cwg_defects.html#301">301</A>,
<A HREF="
     cwg_defects.html#372">372</A>,
<A HREF="
     cwg_defects.html#382">382</A>,
<A HREF="
     cwg_defects.html#391">391</A>, and
<A HREF="
     cwg_active.html#399">399</A>.
</LI>

<LI>
<B>Revision 26: 2003-04-25:</B>  Reflected deliberations from
the Oxford (April, 2003) meeting.  Added new issues 402-411.
</LI>

<LI>
<B>Revision 25: 2003-03-03:</B> Added new issues 390-401, updated
<A HREF="
     cwg_defects.html#214">issue 214</A>.
</LI>
<LI>
<B>Revision 24: 2002-11-08:</B> Reflected deliberations from the
Santa Cruz (October, 2002) meeting.  Added new issues 379-389.
</LI>

<LI>
<B>Revision 23: 2002-09-10:</B> Added new issues 355-378, updated
<A HREF="
     cwg_defects.html#298">issue 298</A> and <A HREF="
     cwg_defects.html#214">issue 214</A>.
</LI>
<LI>
<B>Revision 22: 2002-05-10:</B> Reflected deliberations from the
Curacao (April, 2002) meeting.  Added issues 342-354.
</LI>
<LI>
<B>Revision 21: 2002-03-11:</B> Added new issues 314-341, updated issues
<A HREF="
     cwg_closed.html#132">132</A>,
<A HREF="
     cwg_defects.html#214">214</A>,
<A HREF="
     cwg_defects.html#244">244</A>,
<A HREF="
     cwg_defects.html#245">245</A>,
<A HREF="
     cwg_defects.html#254">254</A>,
<A HREF="
     cwg_active.html#255">255</A>,
<A HREF="
     cwg_defects.html#283">283</A>.
</LI>

<LI>
<B>Revision 20: 2001-11-09:</B> Reflected deliberations from the
Redmond (October, 2001) meeting.  Added issue <A HREF="
     cwg_closed.html#313">313</A>.
</LI>

<LI>
<B>Revision 19: 2001-09-12:</B> Added new issues 289-308, updated
issues <A HREF="
     cwg_defects.html#222">222</A>, <A HREF="
     cwg_defects.html#261">261</A>,
<A HREF="
     cwg_defects.html#270">270</A>.
</LI>

<LI>
<B>Revision 18: 2001-05-19:</B> Reflected deliberations from the
Copenhagen (April, 2001) meeting.  Added new issues 282-288.
</LI>

<LI>
<B>Revision 17: 2001-04-29:</B> Added new issues 276-81.
</LI>

<LI>
<B>Revision 16: 2001-03-27:</B> Updated <A HREF="
     cwg_active.html#138">issue 138</A> to discuss the interaction of <I>using-declaration</I>s
and "forward declarations."  Noted a problem with the proposed
resolution of <A HREF="
     cwg_defects.html#139">issue 139</A>.  Added some
new discussion to  <A HREF="
     cwg_defects.html#115">issue 115</A>.  Added
proposed resolution for <A HREF="
     cwg_defects.html#160">issue 160</A>.  Updated
address of C++ FAQ.  Added new issues 265-275.
</LI>

<LI>
<B>Revision 15: 2000-11-18:</B> Reflected deliberations from the
Toronto (October, 2000) meeting; moved the discussion of empty and
fully-initialized const objects from <A HREF="
     cwg_defects.html#78">issue 78</A> into <A HREF="
     cwg_active.html#253">new issue 253</A>;
added new issues 254-264.
</LI>

<LI>
<B>Revision 14: 2000-10-21:</B> Added issues 246-252; added an extra
question to <A HREF="
     cwg_defects.html#221">issue 221</A> and changed its
status back to "review."
</LI>

<LI>
<B>Revision 13: 2000-09-16:</B> Added issues 229-245; changed status
of <A HREF="
     cwg_defects.html#106">issue 106</A> to "review" because of problem
detected in proposal; added wording for issues <A HREF="
     cwg_defects.html#87">87</A> and <A HREF="
     cwg_defects.html#216">216</A> and moved to "review"
status; updated discussion of issues
<A HREF="
     cwg_defects.html#5">5</A>,
<A HREF="
     cwg_defects.html#78">78</A>,
<A HREF="
     cwg_defects.html#198">198</A>,
<A HREF="
     cwg_active.html#203">203</A>, and
<A HREF="
     cwg_defects.html#222">222</A>.
</LI>

<LI>
<B>Revision 12: 2000-05-21:</B> Reflected deliberations from the
Tokyo (April, 2000) meeting; added new issues 222-228.
</LI>

<LI>
<B>Revision 11, 2000-04-13:</B> Added proposed wording and moved
issues
<A HREF="
     cwg_defects.html#62">62</A>,
<A HREF="
     cwg_defects.html#73">73</A>,
<A HREF="
     cwg_defects.html#89">89</A>,
<A HREF="
     cwg_defects.html#94">94</A>,
<A HREF="
     cwg_defects.html#106">106</A>,
<A HREF="
     cwg_defects.html#121">121</A>,
<A HREF="
     cwg_defects.html#134">134</A>,
<A HREF="
     cwg_defects.html#142">142</A>, and
<A HREF="
     cwg_defects.html#145">145</A>
to "review" status.  Moved <A HREF="
     cwg_closed.html#13">issue 13</A>
from "extension" to "open" status because of recent additional
discussion.
Added new issues 217-221.
</LI>

<LI>
<B>Revision 10, 2000-03-21:</B> Split the issues list and indices into
multiple documents.  Added further discussion to issues
<A HREF="
     cwg_defects.html#84">84</A> and <A HREF="
     cwg_defects.html#87">87</A>.
Added proposed wording and moved issues
<A HREF="
     cwg_defects.html#1">1</A>,
<A HREF="
     cwg_defects.html#69">69</A>,
<A HREF="
     cwg_defects.html#85">85</A>,
<A HREF="
     cwg_defects.html#98">98</A>,
<A HREF="
     cwg_defects.html#105">105</A>,
<A HREF="
     cwg_defects.html#113">113</A>,
<A HREF="
     cwg_closed.html#132">132</A>, and
<A HREF="
     cwg_defects.html#178">178</A>
to "review" status.
Added new issues 207-216.
</LI>

<LI><B>Revision 9, 2000-02-23:</B> Incorporated decisions from the
October, 1999 meeting of the Committee;

added issues 174 through 206.</LI>

<LI><B>Revision 8, 1999-10-13:</B> Minor editorial changes to issues
<A HREF="
     cwg_defects.html#90">90</A> and
<A HREF="
     cwg_defects.html#24">24</A>; updated issue
<A HREF="
     cwg_defects.html#89">89</A> to include a related question;
added issues
<A HREF="
     cwg_closed.html#169">169</A>,
<A HREF="
     cwg_active.html#170">170</A>,
<A HREF="
     cwg_defects.html#171">171</A>,
<A HREF="
     cwg_defects.html#172">172</A>, and
<A HREF="
     cwg_defects.html#173">173</A>.</LI>

<LI><B>Revision 7, 1999-09-14:</B> Removed unneeded change to
14.7.3
 [temp.expl.spec] paragraph 9 from
<A HREF="
     cwg_defects.html#24">issue 24</A>; changed
<A HREF="
     cwg_defects.html#85">issue 85</A> to refer to
3.4.4
 [basic.lookup.elab];
added issues
<A HREF="
     cwg_defects.html#122">122</A>,
<A HREF="
     cwg_defects.html#123">123</A>,
<A HREF="
     cwg_defects.html#124">124</A>,
<A HREF="
     cwg_defects.html#125">125</A>,
<A HREF="
     cwg_defects.html#126">126</A>,
<A HREF="
     cwg_defects.html#127">127</A>,
<A HREF="
     cwg_defects.html#128">128</A>,
<A HREF="
     cwg_active.html#129">129</A>,
<A HREF="
     cwg_closed.html#130">130</A>,
<A HREF="
     cwg_defects.html#131">131</A>,
<A HREF="
     cwg_closed.html#132">132</A>,
<A HREF="
     cwg_closed.html#133">133</A>,
<A HREF="
     cwg_defects.html#134">134</A>,
<A HREF="
     cwg_defects.html#135">135</A>,
<A HREF="
     cwg_defects.html#136">136</A>,
<A HREF="
     cwg_defects.html#137">137</A>,
<A HREF="
     cwg_active.html#138">138</A>,
<A HREF="
     cwg_defects.html#139">139</A>,
<A HREF="
     cwg_defects.html#140">140</A>,
<A HREF="
     cwg_defects.html#141">141</A>,
<A HREF="
     cwg_defects.html#142">142</A>,
<A HREF="
     cwg_defects.html#143">143</A>,
<A HREF="
     cwg_active.html#144">144</A>,
<A HREF="
     cwg_defects.html#145">145</A>,
<A HREF="
     cwg_active.html#146">146</A>,
<A HREF="
     cwg_defects.html#147">147</A>,
<A HREF="
     cwg_defects.html#148">148</A>,
<A HREF="
     cwg_defects.html#149">149</A>,
<A HREF="
     cwg_active.html#150">150</A>,
<A HREF="
     cwg_defects.html#151">151</A>,
<A HREF="
     cwg_defects.html#152">152</A>,
<A HREF="
     cwg_defects.html#153">153</A>,
<A HREF="
     cwg_closed.html#154">154</A>,
<A HREF="
     cwg_closed.html#155">155</A>,
<A HREF="
     cwg_active.html#156">156</A>,
<A HREF="
     cwg_active.html#157">157</A>,
<A HREF="
     cwg_defects.html#158">158</A>,
<A HREF="
     cwg_defects.html#159">159</A>,
<A HREF="
     cwg_defects.html#160">160</A>,
<A HREF="
     cwg_defects.html#161">161</A>,
<A HREF="
     cwg_defects.html#162">162</A>,
<A HREF="
     cwg_defects.html#163">163</A>,
<A HREF="
     cwg_defects.html#164">164</A>,
<A HREF="
     cwg_closed.html#165">165</A>,
<A HREF="
     cwg_defects.html#166">166</A>,
<A HREF="
     cwg_closed.html#167">167</A>, and
<A HREF="
     cwg_closed.html#168">168</A>.</LI>

<LI><B>Revision 6, 1999-05-31:</B> Moved
<A HREF="
     cwg_closed.html#72">issue 72</A> to "dup" status; added
proposed wording and moved <A HREF="
     cwg_defects.html#90">issue 90</A>
to "review" status; updated <A HREF="
     cwg_defects.html#98">issue 98</A>
with additional question; added issues
<A HREF="
     cwg_active.html#110">110</A>,
<A HREF="
     cwg_active.html#111">111</A>,
<A HREF="
     cwg_defects.html#112">112</A>,
<A HREF="
     cwg_defects.html#113">113</A>,
<A HREF="
     cwg_closed.html#114">114</A>,
<A HREF="
     cwg_defects.html#115">115</A>,
<A HREF="
     cwg_defects.html#116">116</A>,
<A HREF="
     cwg_closed.html#117">117</A>,
<A HREF="
     cwg_defects.html#118">118</A>,
<A HREF="
     cwg_defects.html#119">119</A>,
<A HREF="
     cwg_defects.html#120">120</A>, and
<A HREF="
     cwg_defects.html#121">121</A>.</LI>

<LI><B>Revision 5, 1999-05-24:</B> Reordered issues by status; added revision
history; first public version.</LI>
</UL>

<A NAME="Issue Status"></A>
<H3>Issue status</H3>

<P>Issues progress through various statuses as the Core Language
Working Group and, ultimately, the full PL22.16 and WG21 committees
deliberate and act.  For ease of reference, issues are grouped in these
documents by their status.  Issues have one of the following statuses:</P>

<P><B>Open:</B> The issue is new or the working group has not yet
formed an opinion on the issue.  If a <I>Suggested Resolution</I> is
given, it reflects the opinion of the issue's submitter, not
necessarily that of the working group or the Committee as a whole.</P>

<P><B>Drafting:</B> Informal consensus has been reached in the
working group and is described in rough terms in a <I>Tentative
Resolution</I>, although precise wording for the change is not yet
available.</P>

<P><B>Review:</B> Exact wording of a <I>Proposed Resolution</I> is now
available for an issue on which the working group previously reached
informal consensus.</P>

<P><B>Ready:</B> The working group has reached consensus that the
issue is a defect in the Standard, the <I>Proposed Resolution</I> is
correct, and the issue is ready to forward to the full Committee for
ratification as a proposed defect report.</P>

<P><B>DR:</B> The full Committee has approved the item as a proposed
defect report.  The <I>Proposed Resolution</I> in an issue with this
status reflects the best judgment of the Committee at this time
regarding the action that will be taken to remedy the defect; however,
the current wording of the Standard remains in effect until such time
as a <I>Technical Corrigendum</I> or a revision of the Standard is
issued by ISO.</P>

<P><B>TC1:</B> A DR issue included in Technical Corrigendum 1.
TC1 is a revision of the Standard issued in 2003.</P>

<P><B>CD1:</B> A DR issue not resolved in TC1 but included in
Committee Draft 1.  CD1 was advanced for balloting at the
September, 2008 WG21 meeting.</P>

<P><B>WP:</B> A DR issue whose resolution is reflected in
the current Working Paper.  The Working Paper is a draft for a
future version of the Standard.</P>

<P><B>Dup:</B> The issue is identical to or a subset of another issue,
identified in a <I>Rationale</I> statement.</P>

<P><B>NAD:</B> The working group has reached consensus that the issue
is not a defect in the Standard. A <I>Rationale</I> statement
describes the working group's reasoning.</P>

<P><B>Extension:</B> The working group has reached consensus that the
issue is not a defect in the Standard but is a request for an
extension to the language.  The working group
expresses no opinion on the merits of an issue with this status;
however, the issue will be maintained on the list for possible future
consideration as an extension proposal.</P>
<HR><A NAME="Ready Status"></A><H3>Issues with "Ready" Status</H3>
<HR><A NAME="598"></A><H4>598.
  
Associated namespaces of overloaded functions and function templates
</H4><B>Section: </B>3.4.2&#160;
 [basic.lookup.argdep]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>27 September 2006<BR>


<P>The resolution of <A HREF="
     cwg_defects.html#33">issue 33</A> added the
following wording in 3.4.2
 [basic.lookup.argdep]:</P>

<BLOCKQUOTE>

In addition, if the argument is the name or address of a set of
overloaded functions and/or function templates, its associated classes
and namespaces are the union of those associated with each of the
members of the set: the namespace in which the function or function
template is defined and the classes and namespaces associated with its
(non-dependent) parameter types and return type.

</BLOCKQUOTE>

<P>This wording is self-contradictory: although it claims that the
treatment of overload sets is intended to be &#8220;the union of those
associated with each of the members of the set,&#8221; it says that
the namespace of which each function or function template is a member
is to be considered an associated namespace.  That is different from
the case of a non-overloaded function argument; in that case, because
only the <I>type</I> of the argument is considered, the namespace of
which the function is a member is <I>not</I> an associated namespace.
This should be rectified so that overloaded and unoverloaded functions
really are treated the same.</P>

<P><B>Proposed resolution (June, 2008):</B></P>

<P>Change 3.4.2
 [basic.lookup.argdep] paragraph 2 as follows:</P>

<BLOCKQUOTE>

...In addition, if the argument is the name or address of a set
of overloaded functions and/or function templates, its associated
classes and namespaces are the union of those associated with
each of the members of the set<S>: the namespace in which the
function or function template is defined and</S><B>, i.e.,</B>
the classes and namespaces associated with its (non-dependent)
parameter types and return type.

</BLOCKQUOTE>

<BR><BR><HR><A NAME="571"></A><H4>571.
  
References declared <TT>const</TT>
</H4><B>Section: </B>3.5&#160;
 [basic.link]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Dave Abrahams
 &#160;&#160;&#160;

 <B>Date: </B>31 March 2006<BR>




<P>According to 3.5
 [basic.link] paragraph 3,</P>

<BLOCKQUOTE>

<P>A name having namespace scope (3.3.5
 [basic.scope.namespace]) has
internal linkage if it is the name of</P>

<UL>
<LI><P>an object, reference, function or function template that is
explicitly declared <TT>static</TT> or,</P></LI>

<LI><P>an object or reference that is explicitly
declared <TT>const</TT> and neither explicitly
declared <TT>extern</TT> nor previously declared to have external
linkage;</P></LI>

</UL>

</BLOCKQUOTE>

<P>It is not possible to declare a reference to be <TT>const</TT>.</P>

<P><B>Proposed resolution (March, 2008):</B></P>

<P>Change 3.5
 [basic.link] paragraph 3 as indicated (note
addition of punctuation in the first bullet):</P>

<BLOCKQUOTE>

<P>A name having namespace scope (3.3.5
 [basic.scope.namespace]) has
internal linkage if it is the name of</P>

<UL>
<LI><P>an object, reference, function<B>,</B> or function
template that is explicitly declared <TT>static</TT><B>;</B>
or,</P></LI>

<LI><P>an object <S>or reference</S> that is explicitly declared
<TT>const</TT> and neither explicitly declared <TT>extern</TT>
nor previously declared to have external linkage; or</P></LI>

<LI><P>a data member of an anonymous union.</P></LI>

</UL>

</BLOCKQUOTE>

<BR><BR><HR><A NAME="665"></A><H4>665.
  
Problems in the specification of <TT>dynamic_cast</TT>
</H4><B>Section: </B>5.2.7&#160;
 [expr.dynamic.cast]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daniel Kr&#252;gler
 &#160;&#160;&#160;

 <B>Date: </B>1 December 2007<BR>


<P>At least one implementation accepts the following example as
well-formed (returning a null pointer at runtime), although others
reject it at compile time:</P>

<PRE>
    struct A { virtual ~A(); };
    struct B: private A { } b;
    A* pa = dynamic_cast&lt;A*&gt;(&amp;b);
</PRE>

<P>Presumably the intent of 5.2.7
 [expr.dynamic.cast] paragraph 5
is that all up-casts (converting from derived to base) are to be
handled at compile time, regardless of whether the class involved is
polymorphic or not:</P>

<BLOCKQUOTE>

If <TT>T</TT> is &#8220;pointer to <I>cv1</I> <TT>B</TT>&#8221;
and <TT>v</TT> has type &#8220;pointer to <I>cv2</I> <TT>D</TT>&#8221;
such that <TT>B</TT> is a base class of <TT>D</TT>, the result is a
pointer to the unique <TT>B</TT> subobject of the <TT>D</TT> object
pointed to by <TT>v</TT>. Similarly, if <TT>T</TT> is &#8220;reference
to <I>cv1</I> <TT>B</TT>&#8221; and <TT>v</TT> has
type <I>cv2</I> <TT>D</TT> such that <TT>B</TT> is a base class
of <TT>D</TT>, the result is the unique <TT>B</TT> subobject of
the <TT>D</TT> object referred to by <TT>v</TT>... In both the pointer
and reference cases, <I>cv1</I> shall be the same cv-qualification as,
or greater cv-qualification than, <I>cv2</I>, and <TT>B</TT> shall be
an accessible unambiguous base class of <TT>D</TT>.

</BLOCKQUOTE>

<P>One explanation for the implementation that accepts the example at
compile time is that the final sentence is interpreted as part of the
condition for the applicability of this paragraph, so that this case
falls through into the description of runtime checking that follows.
This (mis-)interpretation is buttressed by the example in paragraph 9,
which reads in significant part:</P>

<PRE>
    class A { virtual void f(); };
    class B { virtual void g(); };
    class D : public virtual A, private B {};
    void g() {
        D d;
        B* bp;
        bp = dynamic_cast&lt;B*&gt;(&amp;d); //<SPAN STYLE="font-family:Times"><I> fails</I></SPAN>
    }
</PRE>

<P>The &#8220;fails&#8221; comment is identical to the commentary on
the lines in the example where the run-time check fails.  If the
interpretation that paragraph 5 is supposed to apply to all up-casts,
presumably this comment should change to &#8220;ill-formed,&#8221; or
the line should be removed from the example altogether.</P>

<P>It should be noted that this interpretation (that the example is
ill-formed and the runtime check applies only to down-casts and
cross-casts) rejects some programs that could plausibly be accepted
and actually work at runtime.  For example,</P>

<PRE>
    struct B { virtual ~B(); };
    struct D: private virtual B { };

    void test(D* pd) {
        B* pb = dynamic_cast&lt;B*&gt;(pd); // #1
    }

    struct D2: virtual B, virtual D {};

    void demo() {
        D2 d2;
        B* pb = dynamic_cast&lt;B*&gt;(&amp;d2); // #2
        test(&amp;d2); // #3
    }
</PRE>

<P>According to the interpretation that paragraph 5 applies,
line #1 is ill-formed.  However, converting from <TT>D2</TT> to
<TT>B</TT> (line #2) is well-formed; if the alternate interpretation
were applied, the conversion in line #1 could succeed when applied
to <TT>d2</TT> (line #3).</P>

<P>One final note: the wording in 5.2.7
 [expr.dynamic.cast]
paragraph 8 is incorrect:</P>

<BLOCKQUOTE>

<P>The run-time check logically executes as follows:</P>

<UL>
<LI><P>If, in the most derived object pointed (referred) to
by <TT>v</TT>, <TT>v</TT> points (refers) to a <TT>public</TT> base
class subobject of a <TT>T</TT> object, and if only one object of
type <TT>T</TT> is derived from the subobject pointed (referred) to by
<TT>v</TT> the result is a pointer (an lvalue referring) to
that <TT>T</TT> object.</P></LI>

<LI><P>Otherwise, if <TT>v</TT> points (refers) to a <TT>public</TT>
base class subobject of the most derived object, and the type of the
most derived object has a base class, of type <TT>T</TT>, that is
unambiguous and <TT>public</TT>, the result is a pointer (an lvalue
referring) to the <TT>T</TT> subobject of the most derived
object.</P></LI>

<LI><P>Otherwise, the run-time check fails.</P></LI>
</UL>

</BLOCKQUOTE>

<P>All uses of <TT>T</TT> in this paragraph treat it as if it were
a class type; in fact, <TT>T</TT> is the type to which the expression
is being cast and thus is either a pointer type or a reference type,
not a class type.</P>

<P><B>Proposed resolution (June, 2008):</B></P>

<OL><LI><P>Change 5.2.7
 [expr.dynamic.cast] paragraph 5 as follows:</P></LI>

<BLOCKQUOTE>

...In both the pointer and reference cases, <S><I>cv1</I> shall be the
same cv-qualification as, or greater cv-qualification than,
<I>cv2</I>, and <TT>B</TT> shall be an accessible unambiguous base
class of <TT>D</TT></S> <B>the program is ill-formed if <I>cv2</I> is
greater cv-qualification than <I>cv1</I> or if <TT>B</TT> is an
inaccessible or ambiguous base class of <TT>D</TT></B>.

</BLOCKQUOTE>

<LI><P>Change the comment in the example in 5.2.7
 [expr.dynamic.cast]
paragraph 9 as follows:</P></LI>

<PRE>
    bp = dynamic_cast&lt;B*&gt;(&amp;d);     //<SPAN STYLE="font-family:Times"><I> <S>fails</S> <B>ill-formed (not a run-time check)</B></I></SPAN>
</PRE>

<LI><P>Change 5.2.7
 [expr.dynamic.cast] paragraph 8 as follows:</P></LI>

<BLOCKQUOTE>

<P><S>The</S> <B>If <TT>C</TT> is the class type to which <TT>T</TT>
points or refers, the</B> run-time check logically executes as
follows:</P>

<UL><LI><P>If, in the most derived object pointed (referred) to by
<TT>v</TT>, <TT>v</TT> points (refers) to a public base class
subobject of a <S><TT>T</TT></S> <B><TT>C</TT></B> object, and if only
one object of type <S><TT>T</TT></S> <B><TT>C</TT></B> is derived from
the subobject pointed (referred) to by <TT>v</TT> the result is a
pointer (an lvalue referring) to that <S><TT>T</TT></S>
<B><TT>C</TT></B> object.</P></LI>

<LI><P>Otherwise, if <TT>v</TT> points (refers) to a public base class
subobject of the most derived object, and the type of the most derived
object has a base class, of type <S><TT>T</TT></S> <B><TT>C</TT></B>,
that is unambiguous and public, the result is a pointer (an lvalue
referring) to the <S><TT>T</TT></S> <B><TT>C</TT></B> subobject of the
most derived object.</P></LI>

<LI><P>Otherwise, the run-time check fails.</P></LI>

</UL>

</BLOCKQUOTE>

</OL>

<BR><BR><HR><A NAME="658"></A><H4>658.
  
Defining <TT>reinterpret_cast</TT> for pointer types
</H4><B>Section: </B>5.2.10&#160;
 [expr.reinterpret.cast]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Dave Abrahams
 &#160;&#160;&#160;

 <B>Date: </B>4 November 2007<BR>


<P>For years I've noticed that people will write code like this to get
the address of an object's bytes:</P>

<PRE>
  void foo(long* p) {
      char* q = reinterpret_cast&lt;char*&gt;(p);  // #1
      // do something with the bytes of *p by using q
  }
</PRE>

<P>When in fact the only portable way to do it according to the standard
is:</P>

<PRE>
  void foo(long* p) {
      char* q = static_cast&lt;char*&gt;(static_cast&lt;void*&gt;(p));  // #2
      // do something with the bytes of *p by using q
  }
</PRE>

<P>I thought <TT>reinterpret_cast</TT> existed so that vendors could
provide some weird platform-specific things.  However, recently Peter
Dimov pointed out to me that if we substitute a class type
for <TT>long</TT> above, <TT>reinterpret_cast</TT> is required to work as
expected by 9.2
 [class.mem] paragraph 18:</P>

<BLOCKQUOTE>

A pointer to a standard-layout struct object, suitably converted using
a <TT>reinterpret_cast</TT>, points to its initial member (or if that
member is a bit-field, then to the unit in which it resides) and vice
versa.

</BLOCKQUOTE>

<P>So there isn't a whole lot of flexibility to do something different
and useful on non-class types.  Are there any implementations for
which #1 actually fails?  If not, I think it would be a good idea to
nail <TT>reinterpret_cast</TT> down so that the standard says it does
what people (correctly) think it does in practice.</P>

<P><B>Proposed resolution (March, 2008):</B></P>

<P>Change 5.2.10
 [expr.reinterpret.cast] paragraph 7 as indicated:</P>

<BLOCKQUOTE>

A pointer to an object can be explicitly converted to a pointer to an
object of different type. <B>When an rvalue <TT>v</TT> of type
&#8220;pointer to <TT>T1</TT>&#8221; is converted to the type
&#8220;pointer to <I>cv</I> <TT>T2</TT>,&#8221; the result is
<TT>static_cast&lt;</TT><I>cv</I> <TT>T2*&gt;(static_cast&lt;</TT><I>cv</I> <TT>void*&gt;(v))</TT>
if both <TT>T1</TT> and <TT>T2</TT> are standard-layout types
(3.9
 [basic.types]) and the alignment requirements of
<TT>T2</TT> are no stricter than those of <TT>T1</TT>.</B>
<S>Except that c</S><B>C</B>onverting an rvalue of type
&#8220;pointer to <TT>T1</TT>&#8221; to the type &#8220;pointer
to <TT>T2</TT>&#8221; (where <TT>T1</TT> and <TT>T2</TT> are object
types and where the alignment requirements of <TT>T2</TT> are no
stricter than those of <TT>T1</TT>) and back to its original type
yields the original pointer value<S>, t</S><B>. T</B>he result of
<B>any other</B> such <S>a</S> pointer conversion is unspecified.

</BLOCKQUOTE>

<BR><BR><HR><A NAME="556"></A><H4>556.
  
Conflicting requirements for acceptable aliasing
</H4><B>Section: </B>5.17&#160;
 [expr.ass]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>30 January 2006<BR>


<P>There appear to be two different specifications for when aliasing
is permitted.  One is in 3.10
 [basic.lval] paragraph 15:</P>

<BLOCKQUOTE>

<P>If a program attempts to access the stored value of an object through
an lvalue of other than one of the following types the behavior is
undefined</P>

<UL>
<LI><P>the dynamic type of the object,</P></LI>

<LI><P>a cv-qualified version of the dynamic type of the
object,</P></LI>

<LI><P>a type similar (as defined in 4.4
 [conv.qual]) to
the dynamic type of the object,</P></LI>

<LI><P>a type that is the signed or unsigned type corresponding to the
dynamic type of the object,</P></LI>

<LI><P>a type that is the signed or unsigned type corresponding to a
cv-qualified version of the dynamic type of the object,</P></LI>

<LI><P>an aggregate or union type that includes one of the
aforementioned types among its members (including, recursively, a
member of a subaggregate or contained union),</P></LI>

<LI><P>a type that is a (possibly cv-qualified) base class type of the
dynamic type of the object,</P></LI>

<LI><P>a <TT>char</TT> or <TT>unsigned char</TT> type.</P></LI>

</UL>

</BLOCKQUOTE>

<P>There is also a much more restrictive specification in
5.17
 [expr.ass] paragraph 8:</P>

<BLOCKQUOTE>

If the value being stored in an object is accessed from another object
that overlaps in any way the storage of the first object, then the
overlap shall be exact and the two objects shall have the same type,
otherwise the behavior is undefined.

</BLOCKQUOTE>

<P>This affects, for example, the definedness of operations
on union members: when may a value be stored into one union
member and accessed via another.</P>

<P>It should be noted that this conflict existed in C90 and is
unchanged in C99 (see, for example, section 6.5 paragraph 7 and
section 6.5.16.1 paragraph 3 of ISO/IEC 9899:1999, which directly
parallel the sections cited above).</P>

<P><B>Notes from the October, 2006 meeting:</B></P>

<P>This issue is based on a misunderstanding of the intent of the
wording in 5.17
 [expr.ass] paragraph 8.  Instead of
being a general statement about aliasing, it's describing the
situation in which the source of the value being assigned is storage
that overlaps the storage of the target object.  The proposed
resolution should make that clearer rather than changing the
specification.</P>

<P><B>Proposed resolution (June, 2008):</B></P>

<P>Add the following note at the end of 5.17
 [expr.ass]
paragraph 8:</P>

<BLOCKQUOTE>

If the value being stored in an object is accessed from another object
that overlaps in any way the storage of the first object, then the
overlap shall be exact and the two objects shall have the same type,
otherwise the behavior is undefined. <B>[<I>Note:</I> This restriction
applies to the relationship between the left and right sides of the
assignment operation; it is not a statement about how the target of
the assignment may be aliased in general. See 3.10
 [basic.lval]. &#8212;<I>end note</I>]</B>

</BLOCKQUOTE>

<BR><BR><HR><A NAME="652"></A><H4>652.
  
Compile-time evaluation of floating-point expressions
</H4><B>Section: </B>5.19&#160;
 [expr.const]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jens Maurer
 &#160;&#160;&#160;

 <B>Date: </B>3 October 2007<BR>




<P>It was the intention of the constexpr proposal that implementations
be required to evaluate floating-point expressions at compile time.
This intention is not reflected in the actual wording of
5.19
 [expr.const] paragraph 2, bullet 5:</P>

<UL><LI>

a type conversion from a floating-point type to an integral type
(4.9
 [conv.fpint]) unless the conversion is directly applied
to a floating-point literal;

</LI></UL>

<P>This restriction has the effect of forbidding the use of
floating-point expressions in integral constant expressions.</P>

<P><B>Proposed resolution (June, 2008):</B></P>

<P>Delete bullet 6 of 5.19
 [expr.const] paragraph 2:</P>

<UL><S><LI>a type conversion from a floating-point type to an integral
type (4.9
 [conv.fpint]) unless the conversion is directly
applied to a floating-point literal;</LI></S></UL>

<P><B>Notes from the June, 2008 meeting:</B></P>

<P>The CWG agreed with the intent of this issue, that floating-point
calculations should be permitted in constant expressions, but acknowledged
that this opens the possibility of differing results between compile
time and run time. Such issues should be addressed non-normatively,
e.g., via a &#8220;recommended practice&#8221; note like that of C99's
6.4.4.2 or in a technical report.</P>

<P><B>Proposed resolution (August, 2008):</B></P>

<OL>
<LI><P>Delete bullet 6 of 5.19
 [expr.const] paragraph 2:</P></LI>

<UL><S><LI>a type conversion from a floating-point type to an integral
type (4.9
 [conv.fpint]) unless the conversion is directly
applied to a floating-point literal;</LI></S></UL>

<LI><P>Add a new paragraph after 5.19
 [expr.const]
paragraph 3:</P></LI>

<BLOCKQUOTE>

<P>[<I>Note:</I> Although in some contexts constant expressions must be
evaluated during program translation, others may be evaluated during
program execution.  Since this International Standard imposes no
restrictions on the accuracy of floating-point operations, it is
unspecified whether the evaluation of a floating-point expression
during translation yields the same result as the evaluation of the
same expression (or the same operations on the same values) during
program execution. [<I>Footnote:</I> Nonetheless, implementations are
encouraged to provide consistent results, irrespective of whether the
evaluation was actually performed during translation or during program
execution. &#8212;<I>end footnote</I>] [<I>Example:</I></P>

<PRE>
  bool f() {
    char array[1 + int(1 + 0.2 - 0.1 - 0.1)];  //<SPAN STYLE="font-family:Times"><I> Must be evaluated during translation</I></SPAN>
    int size = 1 + int(1 + 0.2 - 0.1 - 0.1);   //<SPAN STYLE="font-family:Times"><I> May be evaluated at runtime</I></SPAN>
    return sizeof(array) == size;
  }
</PRE>

<P>It is unspecified whether the value of <TT>f()</TT> will be
<TT>true</TT> or <TT>false</TT>. &#8212;<I>end example</I>]
&#8212;<I>end note</I>]</P>

</BLOCKQUOTE>

</OL>

<BR><BR><HR><A NAME="569"></A><H4>569.
  
Spurious semicolons at namespace scope should be allowed
</H4><B>Section: </B>7&#160;
 [dcl.dcl]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Matt Austern
 &#160;&#160;&#160;

 <B>Date: </B>20 March 2006<BR>


<P>The grammar in 7
 [dcl.dcl] paragraph 1 says that a
<I>declaration-seq</I> is either <I>declaration</I>
or <I>declaration-seq declaration</I>. Some declarations end with
semicolons and others (e.g. function definitions and namespace
declarations) don't. This means that users who put a semicolon after
every declaration are technically writing ill-formed code. The trouble
is that in this respect the standard is out of sync with reality. It's
convenient to allow semicolons after every declaration, and there's no
implementation difficulty in doing so. All existing compilers accept
this, except in extra-pedantic mode. When all implementations disagree
with the standard, it's time for the standard to change.</P>

<P>Suggested resolution:</P>

<P>In the grammar in 7
 [dcl.dcl] paragraph 11, change the
second line in the definition of <I>declaration-seq</I> to</P>

<UL><I>declaration-seq</I> <TT>;</TT><I><SUB>opt</SUB> declaration</I></UL>

<P><B>Proposed resolution (October, 2006):</B></P>

<OL>
<LI><P>Add the indicated lines to the grammar definitions in
7
 [dcl.dcl] paragraph 1:</P></LI>

<BLOCKQUOTE>

<I>declaration:</I><BR>
<UL>
...<BR>
<I>namespace-definition</I><BR>
<I><B>empty-declaration</B></I>
</UL>
<BR>
...
<BR><BR>
<I>static_assert-declaration:</I><BR>
<UL>
<TT>static_assert ( </TT><I>constant-expression</I><TT> , </TT>
<I>string-literal</I><TT> ) ;</TT>
</UL>
<BR><BR>
<B>
<I>empty-declaration:</I><BR>
<UL><TT>;</TT></UL>
</B>

</BLOCKQUOTE>

<LI><P>Add the following as a new paragraph after 7
 [dcl.dcl]
paragraph 4:</P></LI>

<BLOCKQUOTE>

An <I>empty-declaration</I> has no effect.

</BLOCKQUOTE>
</OL>

<BR><BR><HR><A NAME="576"></A><H4>576.
  
Typedefs in function definitions
</H4><B>Section: </B>7.1.3&#160;
 [dcl.typedef]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jon Caves
 &#160;&#160;&#160;

 <B>Date: </B>21 April 2006<BR>


<P>7.1.3
 [dcl.typedef] paragraph 1 says,</P>

<BLOCKQUOTE>

The <TT>typedef</TT> specifier shall not be used in
a <I>function-definition</I> (8.4
 [dcl.fct.def])...

</BLOCKQUOTE>

<P>Does this mean that the following is ill-formed?</P>

<PRE>
    void f() {
        typedef int INT;
    }
</PRE>

<P><B>Proposed resolution (March, 2008):</B></P>

<P>Change 7.1.3
 [dcl.typedef] paragraph 1 as follows:</P>

<BLOCKQUOTE>

...The <TT>typedef</TT> specifier <S>shall not be used in a
<I>function-definition</I> (8.4
 [dcl.fct.def]), and it</S>
shall not be combined in a <I>decl-specifier-seq</I> with any
other kind of specifier except a <I>type-specifier</I><B>, and it
shall not be used in the declaration of a function parameter nor
in the <I>decl-specifier-seq</I> of a <I>function-definition</I>
(8.4
 [dcl.fct.def])</B>...

</BLOCKQUOTE>

<P><B>Proposed resolution (September, 2008):</B></P>

<P>Change 7.1.3
 [dcl.typedef] paragraph 1 as follows:</P>

<BLOCKQUOTE>

...The <TT>typedef</TT> specifier <S>shall not be used in a
<I>function-definition</I> (8.4
 [dcl.fct.def]), and it</S>
shall not be combined in a <I>decl-specifier-seq</I> with any
other kind of specifier except a <I>type-specifier</I><B>,
and it shall be used neither in the <I>decl-specifier-seq</I> of a
<I>parameter-declaration</I> (8.3.5
 [dcl.fct]) nor in the
<I>decl-specifier-seq</I> of a <I>function-definition</I>
(8.4
 [dcl.fct.def])</B>.

</BLOCKQUOTE>

<BR><BR><HR><A NAME="628"></A><H4>628.
  
The values of an enumeration with no enumerator
</H4><B>Section: </B>7.2&#160;
 [dcl.enum]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Gennaro Prota
 &#160;&#160;&#160;

 <B>Date: </B>15 March 2007<BR>


<P>According to 7.2
 [dcl.enum] paragraph 6, the underlying
type of an enumeration with an empty <I>enumeration-list</I> is
determined as if the <I>enumeration-list</I> contained a single
enumerator with value 0.  Paragraph 7, which specifies the values of
an enumeration and the minimum size of bit-field needed represent
those values needs a similar provision for
empty <I>enumeration-list</I>s.</P>

<P><B>Proposed resolution (March, 2008):</B></P>

<P>Add the indicated sentence to the end of 7.2
 [dcl.enum]
paragraph 5:</P>

<BLOCKQUOTE>

...It is possible to define an enumeration that has values not defined
by any of its enumerators.  <B>If the <I>enumerator-list</I> is empty,
the values of the enumeration are as if the enumeration had a single
enumerator with value 0.</B>

</BLOCKQUOTE>

<BR><BR><HR><A NAME="564"></A><H4>564.
  
Agreement of language linkage or <I>linkage-specification</I>s?
</H4><B>Section: </B>7.5&#160;
 [dcl.link]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>8 March 2006<BR>


<P>The wording of 7.5
 [dcl.link] paragraph 5 is suspect:</P>

<BLOCKQUOTE>

If two declarations of the same function or object specify different
<I>linkage-specification</I>s (that is,
the <I>linkage-specification</I>s of these declarations specify
different <I>string-literal</I>s), the program is ill-formed if the
declarations appear in the same translation unit, and the one
definition rule (3.2) applies if the declarations appear in different
translation units.

</BLOCKQUOTE>

<P>But what if only one of the declarations has a
<I>linkage-specification</I>, while the other is left with the
default C++ linkage?  Shouldn't this restriction be phrased in terms
of the functions&#8217; or objects&#8217; language linkage rather than
<I>linkage-specification</I>s?</P>

<P>(<I>Additional note [wmm]:</I> Is the ODR the proper vehicle for
enforcing this requirement?  This is dealing with declarations, not
necessarily definitions.  Shouldn't this say &#8220;ill-formed, no
diagnostic required&#8221; instead of some vague reference to the ODR?)</P>

<P><B>Proposed resolution (June, 2008):</B></P>

<P>Change 7.5
 [dcl.link] paragraph 5 as follows:</P>

<BLOCKQUOTE>

If two declarations <S>of the same function or object</S> <B>declare
functions with the same name and parameter-type-list (8.3.5
 [dcl.fct]) to be members of the same namespace or declare objects
with the same name to be members of the same namespace</B> <S>specify
different <I>linkage-specification</I>s (that is, the
<I>linkage-specification</I>s of these declarations specify different
<I>string-literal</I>s)</S> <B>and the declarations give the names
different language linkages</B>, the program is ill-formed<S> if the
declarations appear in the same translation unit, and the one
definition rule (3.2
 [basic.def.odr]) applies</S><B>; no
diagnostic is required</B> if the declarations appear in different
translation units.

</BLOCKQUOTE>

<BR><BR><HR><A NAME="645"></A><H4>645.
  
Are bit-field and non-bit-field members layout compatible?
</H4><B>Section: </B>9.2&#160;
 [class.mem]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alan Stokes
 &#160;&#160;&#160;

 <B>Date: </B>9 Aug 2007<BR>




<P>The current wording defining a &#8220;common initial sequence&#8221;
in 9.2
 [class.mem] paragraph 17 does not address the case
in which one member is a bit-field and the corresponding member is
not:</P>

<BLOCKQUOTE>

Two standard-layout structs share a common initial sequence if
corresponding members have layout-compatible types (and, for
bit-fields, the same widths) for a sequence of one or more initial
members.

</BLOCKQUOTE>

<P>Presumably the intent was something like, &#8220;(and, if one
of the pair is a bit-field, the other is also a bit-field of the
same width).&#8221;</P>

<P><B>Proposed Resolution (September, 2008):</B></P>

<P>Change 9.2
 [class.mem] paragraph 18 as follows:</P>
<BLOCKQUOTE>

... Two standard-layout structs share a common initial sequence
if corresponding members have layout-compatible types <S>(and,
for bit-fields, the same widths)</S> <B>and either neither member
is a bit-field or both are bit-fields with the same widths</B>
for a sequence of one or more initial members.

</BLOCKQUOTE>

<BR><BR><HR><A NAME="650"></A><H4>650.
  
Order of destruction for temporaries bound to the returned value of a function
</H4><B>Section: </B>12.2&#160;
 [class.temporary]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>14 Aug 2007<BR>


<P>In describing the order of destruction of temporaries,
12.2
 [class.temporary] paragraphs 4-5 say,</P>

<BLOCKQUOTE>

<P>There are two contexts in which temporaries are destroyed at a
different point than the end of the full-expression...</P>

<P>The second context is when a reference is bound to a
temporary...  A temporary bound to the returned value in a function
return statement (6.6.3
 [stmt.return]) persists until the
function exits.</P>

</BLOCKQUOTE>

<P>The following example illustrates the issues here:</P>

<PRE>
    struct S {
        ~S();
    };

    S&amp; f() {
        S s;            // #1
        return
            (S(),       // #2
             S());      // #3
    }
</PRE>

<P>If the return type of <TT>f()</TT> were simply <TT>S</TT> instead
of <TT>S&amp;</TT>, the two temporaries would be destroyed at the end
of the full-expression in the <TT>return</TT> statement in reverse
order of their construction, followed by the destruction of the
variable <TT>s</TT> at block-exit, i.e., the order of destruction
of the <TT>S</TT> objects would be #3, #2, #1.</P>

<P>Because the temporary #3 is bound to the returned value, however,
its lifetime is extended beyond the end of the full-expression, so
that <TT>S</TT> object #2 is destroyed before #3.</P>

<P>There are two problems here.  First, it is not clear what
&#8220;until the function exits&#8221; means.  Does it mean that
the temporary is destroyed as part of the normal block-exit
destructions, as described in 6.6
 [stmt.jump] paragraph 2:</P>

<BLOCKQUOTE>

On exit from a scope (however accomplished), destructors (12.4
 [class.dtor]) are called for all constructed objects with automatic
storage duration (3.7.3
 [basic.stc.auto]) (named objects or
temporaries) that are declared in that scope, in the reverse order of
their declaration.

</BLOCKQUOTE>

<P>Or is the point of destruction for #3
<I>after</I> the destruction of the &#8220;constructed objects...
that are <I>declared</I> [emphasis mine] in that scope&#8221;
(because temporary #3 was not &#8220;declared&#8221;)?  I.e.,
should #3 be destroyed before or after #1?</P>

<P>The other problem is that, according to the recollection of one
of the participants responsible for this wording, the intent was not
to extend the lifetime of #3 but simply to emphasize that its
lifetime ended before the function returned, i.e., that the result of
<TT>f()</TT> could not be used without causing undefined behavior.
This is also consistent with the treatment of this example by many
implementations; MSVC++, g++, and EDG all destroy #3 before #2.</P>

<P><U>Suggested resolution:</U></P>

<P>Change 12.2
 [class.temporary] paragraph 5 as indicated:</P>

<BLOCKQUOTE>

<S>A</S> <B>The lifetime of a</B> temporary bound to the returned
value in a function return statement (6.6.3
 [stmt.return])
<S>persists until the function exits</S> <B>is not extended; it is
destroyed at the end of the full-expression in the return statement</B>.

</BLOCKQUOTE>

<P><B>Proposed resolution (June, 2008):</B></P>

<P>Change 12.2
 [class.temporary] paragraph 5 as follows (converting
the running text into a bulleted list and making the indicated edits
to the wording):</P>

<BLOCKQUOTE>

... The temporary to which the reference is bound or the temporary
that is the complete object of a subobject to which the reference is
bound persists for the lifetime of the reference except<B>:</B> <S>as
specified below.</S>

<UL><LI><P>A temporary bound to a reference member in a constructor's
ctor-initializer (12.6.2
 [class.base.init]) persists until the
constructor exits.</P></LI>

<LI><P>A temporary bound to a reference parameter in a function call
(5.2.2
 [expr.call]) persists until the completion of the full
expression containing the call.</P></LI>

<LI><P><S>A</S> <B>The lifetime of a</B> temporary bound to the
returned value in a function return statement (6.6.3
 [stmt.return]) <S>persists until the function exits</S> <B>is not extended; the
temporary is destroyed at the end of the full-expression in the return
statement.</B></P></LI>

</UL>

<P>The destruction of a temporary whose lifetime is not extended...</P>

</BLOCKQUOTE>

<BR><BR><HR><A NAME="542"></A><H4>542.
  
Value initialization of arrays of POD-structs
</H4><B>Section: </B>12.6&#160;
 [class.init]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alisdair Meredith
 &#160;&#160;&#160;

 <B>Date: </B>27 October 2005<BR>


<P>12.6
 [class.init] paragraph 2 says,</P>

<BLOCKQUOTE>

When an array of class objects is initialized (either explicitly or
implicitly), the constructor shall be called for each element of the
array, following the subscript order;

</BLOCKQUOTE>

<P>That implies that, given</P>

<PRE>
    struct POD {
      int x;
    };

    POD data[10] = {};
</PRE>

<P>this should call the implicitly declared default ctor 10 times,
leaving 10 uninitialized ints, rather than value initialize each
member of data, resulting in 10 initialized ints (which is required
by 8.5.1
 [dcl.init.aggr] paragraph 7).</P>

<P>I suggest rephrasing along the lines:</P>

<BLOCKQUOTE>

When an array is initialized (either explicitly or implicitly), each
element of the array shall be initialized in turn, following the
subscript order;

</BLOCKQUOTE>

<P>This would allow for PODs and other classes with a dual nature under
value/default initialization, and cover copy initialization for arrays
too.</P>

<P><B>Proposed resolution (October, 2006):</B></P>

<P>Change 12.6
 [class.init] paragraph 3 as follows:</P>

<BLOCKQUOTE>

When an array of class objects is initialized (either explicitly or
implicitly) <B>and the elements are initialized by constructor</B>,
the constructor shall be called for each element of the array,
following the subscript order; see 8.3.4
 [dcl.array].

</BLOCKQUOTE>

<BR><BR><HR><A NAME="641"></A><H4>641.
  
Overload resolution and conversion-to-same-type operators
</H4><B>Section: </B>13.3.2&#160;
 [over.match.viable]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Nathan Sidwell
 &#160;&#160;&#160;

 <B>Date: </B>2 Aug 2007<BR>




<P>12.3.2
 [class.conv.fct] paragraph 1 says,</P>

<BLOCKQUOTE>

A conversion function is never used to convert a (possibly
cv-qualified) object to the (possibly cv-qualified) same object
type (or a reference to it), to a (possibly cv-qualified) base
class of that type (or a reference to it), or to (possibly
cv-qualified) void.

</BLOCKQUOTE>

<P>At what point is this enforced, and how is it enforced?</P>

<OL>

<LI>Does such a user-declared conversion operator participate in
overload resolution? Or is it never entered into the overload
set?</LI>

<LI>If it does participate in overload resolution, what happens
if it is selected?  Is the program ill-formed (and diagnostic
required), or is it silently ignored?  The above wording doesn't
really make it clear.</LI>

</OL>

<P>Consider this test case:</P>

<PRE>
    struct abc;

    struct xyz {
       xyz();

       xyz(xyz &amp;);

       operator xyz&amp; (); // #1
       operator abc&amp; (); // #2
    };

    struct abc : xyz {};

    void foo(xyz &amp;);

    void bar() {
             foo (xyz ());
    }
</PRE>

<P>If such conversion functions are part of the overload set, #1
is a better conversion than #2 to convert the temporary xyz
object to a non-const reference required for foo's operand.  If
such conversion functions are not part of the overload set, then
#2 would be selected, and AFAICT the program would be well
formed.</P>

<P>If the conversion functions are not part of the overload set,
then it would seem one cannot take their address.  For instance,
adding the following line to the above test case would find no
suitable function:</P>

<PRE>
    xyz &amp;(xyz::*ptr) () = &amp;xyz::operator xyz &amp;;
</PRE>

<P><B>Notes from the October, 2007 meeting:</B></P>

<P>The intent of 12.3.2
 [class.conv.fct] paragraph 1 is that
overload resolution not be attempted at all for the listed cases;
that is, if the target type is <TT>void</TT>, the object's type, or a
base of the object's type, the conversion is done directly without
considering any conversion functions.  Consequently, the questions about
whether the conversion function is part of the overload set or not
are moot.  The wording will be changed to make this clearer.</P>

<P><B>Proposed Resolution (October, 2007):</B></P>

<P>Change the footnote in 12.3.2
 [class.conv.fct] paragraph 1 as
follows:</P>

<BLOCKQUOTE>

A conversion function is never used to convert a (possibly
cv-qualified) object to the (possibly cv-qualified) same object type
(or a reference to it), to a (possibly cv-qualified) base class of
that type (or a reference to it), or to (possibly cv-qualified) void.
[<I>Footnote:</I> <B>These conversions are considered as standard
conversions for the purposes of overload resolution
(13.3.3.1
 [over.best.ics], 13.3.3.1.4
 [over.ics.ref])
and therefore initialization (8.5
 [dcl.init]) and
explicit casts (5.2.9
 [expr.static.cast]).  A conversion to
<TT>void</TT> does not invoke any conversion function (5.2.9
 [expr.static.cast]).</B> Even though never directly called to perform a
conversion, such conversion functions can be declared and can
potentially be reached through a call to a virtual conversion function
in a base class &#8212;<I>end footnote</I>]

</BLOCKQUOTE>

<P><B>Additional note (March, 2008):</B></P>

<P>A slight change to the example above indicates that there is a
need for a normative change as well as the clarification of the
rationale in the October, 2007 proposed resolution.  If the
declaration of <TT>foo</TT> were changed to</P>

<PRE>
    void foo(const xyz&amp;);
</PRE>

<P>with the current wording, the call <TT>foo(xyz())</TT> would
be interpreted as <TT>foo(xyz().operator&#160;abc&amp;())</TT> instead
of binding the parameter directly to the rvalue, which is clearly
wrong.</P>

<P><B>Proposed resolution (March, 2008):</B></P>

<OL>
<LI><P>Change the footnote in 12.3.2
 [class.conv.fct] paragraph 1
as described in the October, 2007 proposed resolution.</P></LI>

<LI><P>Change 8.5.3
 [dcl.init.ref] paragraph 5 as follows:</P></LI>

<BLOCKQUOTE>

<P>A reference to type &#8220;<I>cv1</I> <TT>T1</TT>&#8221; is
initialized by an expression of type &#8220;<I>cv2</I>
<TT>T2</TT>&#8221; as follows:</P>

<UL>
<LI><P>If the initializer expression</P></LI>

<UL>
<LI><P>is an lvalue (but is not a bit-field), and
&#8220;<I>cv1</I> <TT>T1</TT>&#8221; is reference-compatible with
&#8220;<I>cv2</I> <TT>T2</TT>,&#8221; or</P></LI>

<LI><P>has a class type (i.e., <TT>T2</TT> is a class type)<B>,
where <TT>T1</TT> is not reference-related to <TT>T2</TT>,</B>
and can be implicitly converted to an lvalue of type
&#8220;<I>cv3</I> <TT>T3</TT>,&#8221; where &#8220;<I>cv1</I>
<TT>T1</TT>&#8221; is reference-compatible with &#8220;<I>cv3</I>
<TT>T3</TT>&#8221; [<I>Footnote:</I> This requires a conversion
function (12.3.2
 [class.conv.fct]) returning a reference
type. &#8212;<I>end footnote</I>] (this conversion is selected by
enumerating the applicable conversion functions (13.3.1.6
 [over.match.ref]) and choosing the best one through overload
resolution (13.3
 [over.match])),</P></LI>

</UL>

<P>then...</P>

</UL>

</BLOCKQUOTE>

<P><I>[Drafting note: this resolution makes the example in the
issue description ill-formed.]</I></P>

</OL>

<BR><BR><HR><A NAME="588"></A><H4>588.
  
Searching dependent bases of classes local to function templates
</H4><B>Section: </B>14.6.2&#160;
 [temp.dep]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Widman
 &#160;&#160;&#160;

 <B>Date: </B>21 June 2006<BR>




<P>14.6.2
 [temp.dep] paragraph 3 reads,</P>

<BLOCKQUOTE>

In the definition of a class template or a member of a class template,
if a base class of the class template depends on
a <I>template-parameter</I>, the base class scope is not examined
during unqualified name lookup either at the point of definition of
the class template or member or during an instantiation of the class
template or member.

</BLOCKQUOTE>

<P>This wording applies only to definitions of class templates and
members of class templates.  That would make the following program
ill-formed (but it probably should be well-formed):</P>

<PRE>
    struct B{ void f(int); };

    template&lt;class T&gt; struct D: B { };

    template&lt;class T&gt; void g() {
       struct B{ void f(); };
       struct A: D&lt;T&gt; {
           B m;
       };
       A a;
       a.m.f(); //<SPAN STYLE="font-family:Times"><I> Presumably, we want </I></SPAN>::g()::B::f()<SPAN STYLE="font-family:Times"><I>, not </I></SPAN>::B::f(int)
    }

    int main () {
       g&lt;int&gt;();
       return 0;
    }
</PRE>

<P>I suspect the wording should be something like</P>

<BLOCKQUOTE>

In the definition of a class template <B>or a class defined
(directly or indirectly) within the scope of a class template or
function template</B>, if a base class...

</BLOCKQUOTE>

<P>That should also include deeply nested classes in templates, local
classes of non-template member functions of member classes of class
templates, etc.</P>

<P><B>Proposed resolution (October, 2006):</B></P>

<P>Change 14.6.2
 [temp.dep] paragraph 3 as follows:</P>

<BLOCKQUOTE>

In the definition of a <B>class or</B> class template <S>or a member
of a class template</S>, if a base class <S>of the class template</S>
depends on a <I>template-parameter</I>, the base class scope is not
examined during unqualified name lookup either at the point of
definition of the class template or member or during an instantiation
of the class template or member.

</BLOCKQUOTE>

<BR><BR><HR><A NAME="499"></A><H4>499.
  
Throwing an array of unknown size
</H4><B>Section: </B>15.1&#160;
 [except.throw]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>19 Jan 2005<BR>


<P>According to 15.1
 [except.throw] paragraph 3,</P>

<BLOCKQUOTE>

The type of the <I>throw-expression</I> shall not be an incomplete
type, or a pointer to an incomplete type other than (possibly
cv-qualified) <TT>void</TT>.

</BLOCKQUOTE>

<P>This disallows cases like the following, because <TT>str</TT> has
an incomplete type (an array of unknown size):</P>

<PRE>
    extern const char str[];
    void f() {
        throw str;
    }
</PRE>

<P>The array-to-pointer conversion is applied to the operand of
<TT>throw</TT>, so there's no problem creating the exception object,
which is the reason for the restriction on incomplete types.  I
believe this case should be permitted.</P>

<P><B>Notes from the April, 2005 meeting:</B></P>

<P>The CWG agreed that the example should be permitted.  Note
that the reference to <I>throw-expression</I> in the cited text
is incorrect; a <I>throw-expression</I> includes the <TT>throw</TT>
keyword and is always of type <TT>void</TT>.  This wording problem
is addressed in the proposed resolution for <A HREF="
     cwg_active.html#475">issue 475</A>.</P>

<P><B>Proposed resolution (October, 2006)</B></P>

<P>Change 15.1
 [except.throw] paragraph 3 as indicated:</P>

<BLOCKQUOTE>

...<S>The type of the <I>throw-expression</I> shall not</S> <B>If the type
of the exception object would</B> be an incomplete type,
or a pointer to an incomplete type other than (possibly cv-qualified)
<TT>void</TT> <B>the program is ill-formed</B>...

</BLOCKQUOTE>

<BR><BR><HR><A NAME="668"></A><H4>668.
  
Throwing an exception from the destructor of a local static object
</H4><B>Section: </B>15.5.1&#160;
 [except.terminate]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daniel Kr&#252;gler
 &#160;&#160;&#160;

 <B>Date: </B>16 December 2007<BR>


<P>The destruction of local static objects occurs at the same time as
that of non-local objects (3.6.3
 [basic.start.term] paragraph 1) and
the execution of functions registered with <TT>std::atexit</TT>
(paragraph 3).  According to 15.5.1
 [except.terminate] paragraph 1,
<TT>std::terminate</TT> is called if a destructor for a non-local
object or a function registered with <TT>std::atexit</TT> exits via
an exception, but the Standard is silent about the result of throwing
an exception from a destructor for a local static object.  Presumably
this is an oversight and the same rules should apply to destruction of
local static objects.</P>

<P><B>Proposed resolution (September, 2008):</B></P>

<P>Change 15.5.1
 [except.terminate] paragraph 1, fourth bullet as
indicated, and add an additional bullet to follow it:</P>

<UL>
<LI><P>when construction <S>or destruction</S> of a non-local
object with static or thread storage duration exits using an
exception (3.6.2
 [basic.start.init]), or</P></LI>

<LI><P><B>when destruction of an object with static or thread
storage duration exits using an exception (3.6.3
 [basic.start.term]), or</B></P></LI> </UL>

<BR><BR><BR><BR><HR><A NAME="Review Status"></A><H3>Issues with "Review" Status</H3>
<HR><A NAME="554"></A><H4>554.
  
Definition of &#8220;declarative region&#8221; and &#8220;scope&#8221;
</H4><B>Section: </B>3.3&#160;
 [basic.scope]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Gabriel Dos Reis
 &#160;&#160;&#160;

 <B>Date: </B>29 December 2005<BR>




<P>The various uses of the term &#8220;declarative region&#8221;
throughout the Standard indicate that the term is intended to refer
to the entire block, class, or namespace that contains a given
declaration.  For example, 3.3
 [basic.scope] paragraph 2
says, in part:</P>

<BLOCKQUOTE>

<P>[<I>Example:</I> in</P>

<PRE>
    int j = 24;
    int main()
    {
        int i = j, j;
        j = 42;
    }
</PRE>

<P>The declarative region of the first <TT>j</TT> includes the entire
example... The declarative region of the second declaration
of <TT>j</TT> (the <TT>j</TT> immediately before the semicolon)
includes all the text between <TT>{</TT> and <TT>}</TT>...</P>

</BLOCKQUOTE>

<P>However, the actual definition given for &#8220;declarative
region&#8221; in 3.3
 [basic.scope] paragraph 1
does not match this usage:</P>

<BLOCKQUOTE>

Every name is introduced in some portion of program text called a
<I>declarative region</I>, which is the largest part of the program in
which that name is <I>valid</I>, that is, in which that name may be
used as an unqualified name to refer to the same entity.

</BLOCKQUOTE>

<P>Because (except in class scope) a name cannot be used before
it is declared, this definition contradicts the statement in the
example and many other uses of the term throughout the Standard.
As it stands, this definition is identical to that of the scope
of a name.</P>

<P>The term &#8220;scope&#8221; is also misused.  The scope of a
declaration is defined in 3.3
 [basic.scope] paragraph 1 as
the region in which the name being declared is valid.  However, there
is frequent use of the phrase &#8220;the scope of a class,&#8221; not
referring to the region in which the class's name is valid but to the
declarative region of the class body, and similarly for namespaces,
functions, exception handlers, etc.  There is even a mention of
looking up a name &#8220;in the scope of the
complete <I>postfix-expression</I>&#8221; (3.4.5
 [basic.lookup.classref] paragraph 3), which is the exact inverse of the scope
of a declaration.</P>

<P>This terminology needs a thorough review to make it logically
consistent.  (Perhaps a discussion of the scope of template
parameters could also be added to section 3.3
 [basic.scope]
at the same time, as all other kinds of scopes are described there.)</P>

<P><B>Proposed resolution (November, 2006):</B></P>

<OL>
<LI><P>Change 3.3
 [basic.scope] paragraph 1 as follows:
</P></LI>

<BLOCKQUOTE>

Every name is introduced in some portion of program text called a
<I>declarative region</I>, which is <S>the largest part of the
program in which that name is <I>valid</I>, that is, in which
that name may be used as an unqualified name to refer to the same
entity</S> <B>a <I>statement</I>, block, function declarator,
<I>function-definition</I>, class, handler, <I>template-declaration</I>,
<I>template-parameter-list</I> of a template
<I>template-parameter</I>, or namespace</B>. In general, each
particular name <S>is valid</S> <B>may be used as an unqualified
name to refer to the entity of its declaration or to the
label</B> only within some possibly discontiguous portion of
program text called its <I>scope</I>. To determine the scope of a
declaration...

</BLOCKQUOTE>

<LI><P>Change 3.3
 [basic.scope] paragraph 3 as follows:
</P></LI>

<BLOCKQUOTE>

The names declared by a declaration are introduced into the
<S>scope in which the declaration occurs</S> <B>declarative
region that directly encloses the declaration</B>, except that
<B><I>declaration-statement</I>s, function parameter names in the
declarator of a <I>function-definition</I>,
<I>exception-declaration</I>s (3.3.2
 [basic.scope.local]),</B>
the presence of a <TT>friend</TT> specifier (11.4
 [class.friend]), certain uses of the
<I>elaborated-type-specifier</I> (7.1.6.3
 [dcl.type.elab]),
and <I>using-directive</I>s (7.3.4
 [namespace.udir]) alter
this general behavior.

</BLOCKQUOTE>

<LI><P>Change 3.3.2
 [basic.scope.local] paragraphs 1-3 and add a
new paragraph 4 before the existing paragraph 4 as follows:
</P></LI>

<BLOCKQUOTE>

<P><S>A name declared in a block (6.3
 [stmt.block]) is
local to that block. Its potential scope begins at its point of
declaration (3.3.1
 [basic.scope.pdecl]) and ends at the end of
its declarative region.</S> <B>The declarative region of a name
declared in a <I>declaration-statement</I> is the directly
enclosing block (6.3
 [stmt.block]). Such a name is local
to the block.</B></P>

<P>The <S>potential scope</S> <B>declarative region</B> of a
function parameter name <S>(including one appearing </S> <B>in
the declarator of a <I>function-definition</I> or</B> in a
<I>lambda-parameter-declaration-clause</I><S>)</S> or of a
function-local predefined variable in a function definition
(8.4
 [dcl.fct.def]) <S>begins at its point of
declaration. If the function has a <I>function-try-block</I> the
potential scope of a parameter or of a function-local predefined
variable ends at the end of the last associated handler,
otherwise it ends at the end of the outermost block of the
function definition. A parameter name</S> <B>is the entire
function definition or <I>lambda-expression</I>. Such a name is
local to the function definition and</B> shall not be redeclared
in <S>the</S> <B>any</B> outermost block of the <S>function
definition nor in the outermost block of any handler associated
with a <I>function-try-block</I></S>
<B><I>function-body</I> (including handlers of a
<I>function-try-block</I>) or <I>lambda-expression</I></B>.</P>

<P><S>The name in a <TT>catch</TT> exception-declaration</S>
<B>The declarative region of a name declared in an
<I>exception-declaration</I> is its entire handler. Such a
name</B> is local to the handler and shall not be redeclared in
the outermost block of the handler.</P>

<P><B>The potential scope of any local name begins at its point
of declaration (3.3.1
 [basic.scope.pdecl]) and ends at the end
of its declarative region.</B></P>

</BLOCKQUOTE>

<LI><P>Change 3.3.4
 [basic.funscope] as indicated:
</P></LI>

<BLOCKQUOTE>

Labels (6.1
 [stmt.label]) have <I>function scope</I> and
may be used anywhere in the function in which they are declared
<B>except in members of local classes (9.8
 [class.local])
of that function</B>. Only labels have function scope.

</BLOCKQUOTE>

<LI><P>Change 6.7
 [stmt.dcl] paragraph 1 as follows:</P></LI>

<BLOCKQUOTE>

<P>A declaration statement introduces one or more new <S>identifiers</S>
<B>names</B> into a block; it has the form</P>

<UL>
<I>declaration-statement:</I>
<UL>
<I>block-declaration</I>
</UL></UL>

<P><B>[<I>Note:</I></B> If <S>an identifier</S> <B>a name</B>
introduced by a declaration was previously declared in an outer
block, the outer declaration is hidden for the remainder of the
block, after which it resumes its force <B>(3.3.10
 [basic.scope.hiding])</B>. <B>&#8212;<I>end note</I>]</B></P>

</BLOCKQUOTE>
</OL>

<P><I>[Drafting notes: This resolution deals almost exclusively
with the unclear definition of &#8220;declarative region.&#8221;
I've left the ambiguous use of &#8220;scope&#8221; alone for now.
However sections 3.3.x all have headings reading &#8220;xxx
scope,&#8221; but they don't mean the scope of a declaration but
the different kinds of declarative regions and their effects on
the scope of declarations contained therein. To me, it looks like
most of 3.4 should refer to &#8220;declarative region&#8221; and
not to &#8220;scope.&#8221;</I></P>

<P><I>The change to 6.7 fixes an &#8220;identifier&#8221; misuse
(e.g., <TT>extern T operator+(T,T);</TT> at block scope
introduces a name but not an identifier) and removes normative
redundancy.]</I></P>

<BR><BR><HR><A NAME="555"></A><H4>555.
  
Pseudo-destructor name lookup
</H4><B>Section: </B>3.4&#160;
 [basic.lookup]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Krzysztof Zelechowski
 &#160;&#160;&#160;

 <B>Date: </B>26 January 2006<BR>


<P>The Standard does not completely specify how to look up the
<I>type-name</I>(s) in a <I>pseudo-destructor-name</I> (5.2
 [expr.post] paragraph 1, 5.2.4
 [expr.pseudo]), and what
information it does have is incorrect and/or in the wrong place.
Consider, for instance, 3.4.5
 [basic.lookup.classref] paragraphs
2-3:</P>

<BLOCKQUOTE>

<P>If the <I>id-expression</I> in a class member access (5.2.5
 [expr.ref]) is an <I>unqualified-id</I>, and the type of the
object expression is of a class type <TT>C</TT> (or of pointer to a
class type <TT>C</TT>), the <I>unqualified-id</I> is looked up in the scope
of class <TT>C</TT>. If the type of the object expression is of pointer to
scalar type, the <I>unqualified-id</I> is looked up in the context of the
complete <I>postfix-expression</I>.</P>

<P>If the <I>unqualified-id</I> is <TT>~</TT><I>type-name</I>, and the
type of the object expression is of a class type <TT>C</TT> (or of
pointer to a class type <TT>C</TT>), the <I>type-name</I> is looked up
in the context of the entire <I>postfix-expression</I> and in the
scope of class <TT>C</TT>. The <I>type-name</I> shall refer to
a <I>class-name</I>. If <I>type-name</I> is found in both contexts,
the name shall refer to the same class type. If the type of the object
expression is of scalar type, the <I>type-name</I> is looked up in the
scope of the complete <I>postfix-expression</I>.</P>

</BLOCKQUOTE>

<P>There are at least three things wrong with this passage with
respect to pseudo-destructors:</P>

<OL>

<LI><P>A pseudo-destructor call (5.2.4
 [expr.pseudo]) is not
a &#8220;class member access&#8221;, so the statements about scalar
types in the object expressions are vacuous: the object expression in
a class member access is required to be a class type or pointer to
class type (5.2.5
 [expr.ref] paragraph 2).</P></LI>

<LI><P>On a related note, the lookup for the <I>type-name</I>(s) in a
pseudo-destructor name should not be described in a section entitled
&#8220;Class member access.&#8221;</P></LI>

<LI><P>Although the class member access object expressions are
carefully allowed to be either a class type or a pointer to a class
type, paragraph 2 mentions only a &#8220;pointer to scalar type&#8221;
(disallowing references) and paragraph 3 deals only with a
&#8220;scalar type,&#8221; presumably disallowing pointers (although
it could possibly be a very subtle way of referring to both non-class
pointers and references to scalar types at once).</P></LI>

</OL>

<P>The other point at which lookup of pseudo-destructors is
mentioned is 3.4.3
 [basic.lookup.qual] paragraph 5:</P>

<BLOCKQUOTE>

If a <I>pseudo-destructor-name</I> (5.2.4
 [expr.pseudo])
contains a <I>nested-name-specifier</I>, the <I>type-name</I>s are
looked up as types in the scope designated by the
<I>nested-name-specifier</I>.

</BLOCKQUOTE>

<P>Again, this specification is in the wrong location (a
<I>pseudo-destructor-name</I> is not a <I>qualified-id</I> and
thus should not be treated in the &#8220;Qualified name lookup&#8221;
section).</P>

<P>Finally, there is no place in the Standard that describes the
lookup for pseudo-destructor calls of the form
<TT>p-&gt;T::~T()</TT> and <TT>r.T::~T()</TT>, where <TT>p</TT>
and <TT>r</TT> are a pointer and reference to scalar, respectively.
To the extent that it gives any guidance at all,
3.4.5
 [basic.lookup.classref] deals only with the case where the
<TT>~</TT> immediately follows the <TT>.</TT> or <TT>-&gt;</TT>, and
3.4.3
 [basic.lookup.qual] deals only with the case where the
<I>pseudo-destructor-name</I> contains
a <I>nested-name-specifier</I> that designates a scope in which
names can be looked up.</P>

<P>See document J16/06-0008 = WG21 N1938 for further discussion of
this and related issues, including <A HREF="
     cwg_defects.html#244">244</A>,
<A HREF="
     cwg_defects.html#305">305</A>, <A HREF="
     cwg_active.html#399">399</A>,
and <A HREF="
     cwg_defects.html#414">414</A>.</P>

<P><B>Proposed resolution (June, 2008):</B></P>

<OL><LI><P>Add a new paragraph following 5.2
 [expr.post]
paragraph 2 as follows:</P></LI>

<BLOCKQUOTE>

When a <I>postfix-expression</I> is followed by a dot <TT>.</TT> or
arrow <TT>-&gt;</TT> operator, the interpretation depends on the type
<TT>T</TT> of the expression preceding the operator. If the operator
is <TT>.</TT>, <TT>T</TT> shall be a scalar type or a complete class
type; otherwise, <TT>T</TT> shall be a pointer to a scalar type or a
pointer to a complete class type. When <TT>T</TT> is a (pointer to) a
scalar type, the <I>postfix-expression</I> to which the operator
belongs shall be a pseudo-destructor call (5.2.4
 [expr.pseudo]); otherwise, it shall be a class member access
(5.2.5
 [expr.ref]).

</BLOCKQUOTE>

<LI><P>Change 5.2.4
 [expr.pseudo] paragraph 2 as follows:</P></LI>

<BLOCKQUOTE>

<S>The left-hand side of the dot operator shall be of scalar type. The
left-hand side of the arrow operator shall be of pointer to scalar
type. This scalar type</S> <B>The type of the expression preceding the dot
operator, or the type to which the expression preceding the arrow
operator points,</B> is the object type...

</BLOCKQUOTE>

<LI><P>Change 5.2.5
 [expr.ref] paragraph 2 as follows:</P></LI>

<BLOCKQUOTE>

For the first option (dot) the type of the first expression (the
object expression) <S>shall be &#8220;class object&#8221; (of a
complete type)</S> <B>is a class type</B>. For the second option
(arrow) the type of the first expression (the pointer expression)
<S>shall be &#8220;pointer to class object&#8221; (of a complete
type)</S> <B>is a pointer to a class type</B>. In these cases, the
<I>id-expression</I> shall name a member of the class or of one of its
base classes.

</BLOCKQUOTE>

<LI><P>Add a new paragraph following 3.4
 [basic.lookup]
paragraph 2 as follows:</P></LI>

<BLOCKQUOTE>

In a <I>pseudo-destructor-name</I> that does not include a
<I>nested-name-specifier</I>, the <I>type-name</I>s are looked up as
types in the context of the complete expression.

</BLOCKQUOTE>

<LI><P>Delete the last sentence of 3.4.5
 [basic.lookup.classref]
paragraph 2:</P></LI>

<BLOCKQUOTE>

If the <I>id-expression</I> in a class member access (5.2.5
 [expr.ref]) is an <I>unqualified-id</I>, and the type of the object
expression is of a class type <TT>C</TT>, the
<I>unqualified-id</I> is looked up in the scope of class
<TT>C</TT>. <S>If the type of the object expression is of pointer to
scalar type, the <I>unqualified-id</I> is looked up in the
context of the complete <I>postfix-expression</I>.</S>

</BLOCKQUOTE>

</OL>

<BR><BR><HR><A NAME="705"></A><H4>705.
  
Suppressing argument-dependent lookup via parentheses
</H4><B>Section: </B>3.4.2&#160;
 [basic.lookup.argdep]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>29 July, 2008<BR>




<P>During the discussion of <A HREF="
     cwg_active.html#704">issue 704</A>,
some people expressed a desire to reconsider whether parentheses
around the name of the function in a function call should suppress
argument-dependent lookup, on the basis that this is overly subtle
and not obvious.  Others pointed out that this technique is used
(both intentionally and inadvertently) in existing code and changing
the behavior could cause problems.</P>

<P>It was also observed that the normative text that specifies this
behavior is itself subtle, relying an a very precise interpretation
of the preposition used in 3.4.2
 [basic.lookup.argdep] paragraph 1:</P>

<BLOCKQUOTE>

When an unqualified name is used as the <I>postfix-expression</I>
in a function call...

</BLOCKQUOTE>

<P>This is taken to mean that something like <TT>(f)(x)</TT>
is not subject to argument-dependent lookup because the name
<TT>f</TT> is used <I>in</I> but not <I>as</I> the
<I>postfix-expression</I>.  This could be confusing, especially
in light of the use of the term <I>postfix-expression</I> to
refer to the name inside the parentheses, not to the
parenthesized expression, in 13.3.1.1
 [over.match.call]
paragraph 1.  If the decision is to preserve this effect of
a parenthesized name in a function call, the wording should
probably be revised to specify it more explicitly.</P>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>The CWG agreed that the suppression of argument-dependent
lookup by parentheses surrounding the <I>postfix-expression</I>
is widely known and used in the C++ community and must be
preserved.  The wording should be changed to make this
effect clearer.</P>

<P><B>Proposed resolution (September, 2008):</B></P>

<P>Change 3.4.2
 [basic.lookup.argdep] paragraph 1 as follows:</P>

<BLOCKQUOTE>

When <S>an unqualified name is used as</S> the
<I>postfix-expression</I> in a function call (<sectkion_ref ref="5.2.2">5.2.2
 [expr.call]</sectkion_ref>) <B>is an <I>unqualified-id</I></B>, other
namespaces not considered during the usual unqualified lookup
(3.4.1
 [basic.lookup.unqual]) may be searched...

</BLOCKQUOTE>

<BR><BR><HR><A NAME="373"></A><H4>373.
  
Lookup on namespace qualified name in using-directive
</H4><B>Section: </B>3.4.6&#160;
 [basic.lookup.udir]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Clark Nelson
 &#160;&#160;&#160;

 <B>Date: </B>15 August 2002<BR>


<P>Is this case valid?  G++ compiles it.</P>
<PRE>
namespace X {
  namespace Y {
    struct X {
      void f()
      {
        using namespace X::Y;
        namespace Z = X::Y;
      }
    };
  }
}
</PRE>
<P>The relevant citation from the standard is
3.4.6
 [basic.lookup.udir]: "When looking up a
namespace-name in a using-directive or namespace-alias-definition, only
namespace names are considered." This statement could reasonably be
interpreted to apply only to the last element of a qualified name, and
that's the way EDG and Microsoft seem to interpret it.</P>

<P>However, since a class can't contain a namespace, it seems to me that this
interpretation is, shall we say, sub optimal. If the X qualifiers in the
above example are interpreted as referring to the struct X, an error of some
sort is inevitable, since there can be no namespace for the qualified name
to refer to. G++ apparently interprets 3.4.6
 [basic.lookup.udir]
as applying to
nested-name-specifiers in those contexts as well, which makes a valid
interpretation of the test possible.</P>

<P>I'm thinking it might be worth
tweaking the words in 3.4.6
 [basic.lookup.udir]
to basically mandate the more useful
interpretation. Of course a person could argue that the difference would
matter only to a perverse program. On the other hand, namespaces were
invented specifically to enable the building of programs that would
otherwise be considered perverse. Where name clashes are concerned, one
man's perverse is another man's real world.</P>

<P><B>Proposed Resolution (November, 2006):</B></P>

<P>Change 3.4.6
 [basic.lookup.udir] paragraph 1 as follows:</P>

<BLOCKQUOTE>

<S>When looking up a <I>namespace-name</I> in a <I>using-directive</I> or
<I>namespace-alias-definition</I>,</S> <B>In a <I>using-directive</I>
or <I>namespace-alias-definition</I>, during the lookup for a
<I>namespace-name</I> or for a name in a <I>nested-name-specifier</I>,</B>
only namespace names are considered.

</BLOCKQUOTE>

<BR><BR><HR><A NAME="597"></A><H4>597.
  
Conversions applied to out-of-lifetime non-POD lvalues
</H4><B>Section: </B>3.8&#160;
 [basic.life]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>27 September 2006<BR>


<P>An lvalue referring to an out-of-lifetime non-POD class objects can
be used in limited ways, subject to the restrictions in
3.8
 [basic.life] paragraph 6:</P>

<BLOCKQUOTE>

if the original object will be or was of a non-POD class type, the
program has undefined behavior if:

<UL>
<LI><P>the lvalue is used to access a non-static data member or call a
non-static member function of the object, or</P></LI>

<LI><P>the lvalue is implicitly converted (4.10
 [conv.ptr])
to a reference to a base class type, or</P></LI>

<LI><P>the lvalue is used as the operand of a <TT>static_cast</TT>
(5.2.9
 [expr.static.cast]) except when the conversion is
ultimately to <I>cv</I> <TT>char&amp;</TT> or <I>cv</I> <TT>unsigned
char&amp;</TT> ), or</P></LI>

<LI><P>the lvalue is used as the operand of a <TT>dynamic_cast</TT>
(5.2.7
 [expr.dynamic.cast]) or as the operand
of <TT>typeid</TT>.</P></LI>
</UL>

</BLOCKQUOTE>

<P>There are at least a couple of questionable things in this list.
First, there is no &#8220;implicit conversion to a reference to a
base class,&#8221; as assumed by the second bullet.  Presumably
this is intended to say that the lvalue is bound to a reference to
a base class, and the cross-reference should be to
8.5.3
 [dcl.init.ref], not to 4.10
 [conv.ptr]
(which deals with pointer conversions).  However, even given that
adjustment, it is not clear why it is forbidden to bind a reference
to a non-virtual base class of an out-of-lifetime object, as that is
just an address offset calculation.  (Binding to a virtual base, of
course, would require access to the value of the object and thus
cannot be done outside the object's lifetime.)</P>

<P>The third bullet also appears questionable.  It's not clear why
<TT>static_cast</TT> is discussed at all here, as the only
permissible <TT>static_cast</TT> conversions involving reference types
and non-POD classes are to references to base or derived classes and
to the same type, modulo cv-qualification; if implicit
&#8220;conversion&#8221; to a base class reference is forbidden in the
second bullet, why would an explicit conversion be permitted in the
third?  Was this intended to refer to
<TT>reinterpret_cast</TT>?  Also, is there a reason to allow char
types but disallow array-of-char types (which are more likely to be
useful than a single char)?</P>

<P><B>Proposed resolution (March, 2008):</B></P>

<OL>
<LI><P>Change 3.8
 [basic.life] paragraph 5 as follows:</P></LI>

<BLOCKQUOTE>

<P>...If the object will be or was of a non-trivial class type,
the program has undefined behavior if:</P>

<UL>
<LI><P>the pointer is used to access a non-static data member or
call a non-static member function of the object, or</P></LI>

<LI><P>the pointer is implicitly converted (<secion_ref ref="4.10">4.10
 [conv.ptr]</secion_ref>) to a pointer to a <B>virtual</B> base class
<S>type</S>, or</P></LI>

<LI><P>the pointer is used as the operand of a
<TT>static_cast</TT> (5.2.9
 [expr.static.cast]) <S>(</S>except
when the conversion is to <S><TT>void*</TT>, or to <TT>void*</TT>
and subsequently to <TT>char*</TT>, or <TT>unsigned char*</TT>).</S>
<B>pointer to <TT>void</TT>, or to pointer to <TT>void</TT> and
subsequently to pointer to <I>cv</I> <TT>char</TT> or pointer to
<I>cv</I> <TT>unsigned char</TT>, or</B></P></LI>

<LI><P>the pointer is used as the operand of a <TT>dynamic_cast</TT>
(5.2.7
 [expr.dynamic.cast])...</P></LI>

</UL>

</BLOCKQUOTE>

<LI><P>Change 3.8
 [basic.life] paragraph 6 as follows:
</P></LI>

<BLOCKQUOTE>

<P>...if the original object will be or was of a non-trivial
class type, the program has undefined behavior if:</P>

<UL>
<LI><P>the lvalue is used to access a non-static data member or
call a non-static member function of the object, or</P></LI>

<LI><P>the lvalue is <S>implicitly converted (4.10
 [conv.ptr])</S> <B>bound</B> to a reference to a <B>virtual</B>
base class <S>type</S> <B>(8.5.3
 [dcl.init.ref])</B>,
or</P></LI>

<LI><P><S>the lvalue is used as the operand of a
<TT>static_cast</TT> (5.2.9
 [expr.static.cast]) except when the
conversion is ultimately to <I>cv</I> <TT>char&amp;</TT> or
<I>cv</I> <TT>unsigned char&amp;</TT>, or</S></P></LI>

<LI><P>the lvalue is used as the operand of a
<TT>dynamic_cast</TT> (5.2.7
 [expr.dynamic.cast]) or as the
operand of <TT>typeid</TT>.</P></LI>

</UL>

</BLOCKQUOTE>

</OL>

<P><I>[Drafting notes: Paragraph 5 was changed to track the
changes to paragraph 6.  See also the resolution for <A HREF="
     cwg_active.html#658">issue 658</A>.]</I></P>

<BR><BR><HR><A NAME="572"></A><H4>572.
  
Standard conversions for non-built-in types
</H4><B>Section: </B>4&#160;
 [conv]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jens Maurer
 &#160;&#160;&#160;

 <B>Date: </B>6 April 2006<BR>


<P>4
 [conv] paragraph 1 says,</P>

<BLOCKQUOTE>

Standard conversions are implicit conversions defined for built-in types.

</BLOCKQUOTE>

<P>However, enumeration types (which take part in the integral
promotions) and class types (which take part in the lvalue-to-rvalue
conversion) are not &#8220;built-in&#8221; types, so the definition of
&#8220;standard conversions&#8221; is wrong.</P>

<P><B>Proposed resolution (October, 2006):</B></P>

<P>Change 4
 [conv] paragraph 1 as follows:</P>

<BLOCKQUOTE>

Standard conversions are implicit conversions <S>defined for built-in types</S> <B>with built-in meaning</B>...

</BLOCKQUOTE>

<BR><BR><HR><A NAME="240"></A><H4>240.
  
Uninitialized values and undefined behavior
</H4><B>Section: </B>4.1&#160;
 [conv.lval]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>8 Aug 2000<BR>




<P>4.1
 [conv.lval] paragraph 1 says,</P>

<BLOCKQUOTE>

If the object to which the lvalue refers is not an object of type
<TT>T</TT> and is not an object of a type derived from <TT>T</TT>, or
if the object is uninitialized, a program that necessitates this
conversion has undefined behavior.

</BLOCKQUOTE>

<P>I think there are at least three related issues around this
specification:</P>

<OL>

<LI><P>Presumably assigning a valid value to an uninitialized
object allows it to participate in the lvalue-to-rvalue
conversion without undefined behavior (otherwise the number of
programs with defined behavior would be vanishingly small :-).
However, the wording here just says "uninitialized" and doesn't
mention assignment.</P></LI>

<LI><P>There's no exception made for <TT>unsigned char</TT> types.
The wording in 3.9.1
 [basic.fundamental] was carefully crafted to
allow use of <TT>unsigned char</TT> to access uninitialized data so
that <TT>memcpy</TT> and such could be written in C++ without
undefined behavior, but this statement undermines that
intent.</P></LI>

<LI><P>It's possible to get an uninitialized rvalue without invoking
the lvalue-to-rvalue conversion.  For instance:</P>

<PRE>
        struct A {
            int i;
            A() { } // no init of A::i
        };
        int j = A().i;  // uninitialized rvalue
</PRE>

<P>There doesn't appear to be anything in the current IS wording
that says that this is undefined behavior.  My guess is that we
thought that in placing the restriction on use of uninitialized
objects in the lvalue-to-rvalue conversion we were catching all
possible cases, but we missed this one.</P></LI>

</OL>

<P>In light of the above, I think the discussion of uninitialized
objects ought to be removed from 4.1
 [conv.lval] paragraph
1.  Instead, something like the following ought to be added to
3.9
 [basic.types] paragraph 4 (which is where the concept of
"value" is introduced):</P>

<BLOCKQUOTE>
Any use of an indeterminate value (5.3.4
 [expr.new],
8.5
 [dcl.init], 12.6.2
 [class.base.init]) of any type
other than <TT>char</TT> or <TT>unsigned char</TT> results in
undefined behavior.
</BLOCKQUOTE>

<P><U>John Max Skaller</U>:</P>

<P><TT>A().i</TT> had better be an lvalue; the rules are wrong.
Accessing a member of a structure requires it be converted to
an lvalue, the above calculation is 'as if':</P>

<PRE>
    struct A {
        int i;
        A *get() { return this; }
    };
    int j = (*A().get()).i;
</PRE>

<P>and you can see the bracketed expression is an lvalue. </P>

<P>A consequence is:</P>

<PRE>
    int &amp;j= A().i; // OK, even if the temporary evaporates
</PRE>

<P><TT>j</TT> now refers to a 'destroyed' value. Any use of <TT>j</TT>
is an error.  But the binding at the time is valid.</P>

<P><B>Proposed Resolution (November, 2006):</B></P>

<OL><LI><P>Add the indicated words to 3.9
 [basic.types] paragraph 4:</P>

<BLOCKQUOTE>

... For trivial types, the value representation is a set of bits in the
object representation that determines a value, which is one discrete
element of an implementation-defined set of values. <B>Any use of an
indeterminate value (5.3.4
 [expr.new], 8.5
 [dcl.init],
12.6.2
 [class.base.init]) of a type other than <TT>unsigned char</TT>
results in undefined behavior.</B>

</BLOCKQUOTE>
</LI>

<LI><P>Change 4.1
 [conv.lval] paragraph 1 as follows:</P>

<BLOCKQUOTE>

If the object to which the lvalue refers is not an object of
type <TT>T</TT> and is not an object of a type derived
from <TT>T</TT>, <S>or if the object is uninitialized,</S> a program
that necessitates this conversion has undefined behavior.

</BLOCKQUOTE>
</LI>

</OL>

<P><B>Additional note (May, 2008):</B></P>

<P>The C committee is dealing with a similar issue in their <A HREF="http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_338.htm">DR336</A>.
According to <A HREF="http://wiki.dinkumware.com/twiki/pub/WG14/DefectReports/dr338_response.txt">
this analysis</A>, they plan to take almost the opposite approach
to the one described above by augmenting the description of their
version of the lvalue-to-rvalue conversion.  The CWG did not
consider that access to an unsigned char might still trap if it
is allocated in a register and needs to reevaluate the proposed
resolution in that light.  See also <A HREF="
     cwg_active.html#129">issue 129</A>.</P>

<BR><BR><HR><A NAME="693"></A><H4>693.
  
New string types and deprecated conversion
</H4><B>Section: </B>4.2&#160;
 [conv.array]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alisdair Meredith
 &#160;&#160;&#160;

 <B>Date: </B>21 April, 2008<BR>




<P>The deprecated conversion from string literal to pointer to
(non-const) character in 4.2
 [conv.array] paragraph 2
has been extended to apply to <TT>char16_t</TT> and
<TT>char32_t</TT> types, but not to UTF8 and raw string
literals.  Is this disparity intentional?  Should it be
extended to all new string types, reverted to just the original
character types, or revoked altogether?</P>

<P>Additional places in the Standard that may need to change
include 15.1
 [except.throw] paragraph 3 and
13.3.3.2
 [over.ics.rank] paragraph 3.</P>

<P><B>Proposed resolution (June, 2008):</B></P>

<OL><LI><P>Remove 4.2
 [conv.array] paragraph 2:</P></LI>

<BLOCKQUOTE>

<S>A string literal (2.13.4
 [lex.string]) with no prefix, with a
<TT>u</TT> prefix, with a <TT>U</TT> prefix, or with an <TT>L</TT>
prefix can be converted to an rvalue of type &#8220;pointer to
<TT>char</TT>&#8221;, &#8220;pointer to <TT>char16_t</TT>&#8221;,
&#8220;pointer to <TT>char32_t</TT>&#8221;, or &#8220;pointer to
<TT>wchar_t</TT>&#8221;, respectively. In any case, the result is a
pointer to the first element of the array. This conversion is
considered only when there is an explicit appropriate pointer target
type, and not when there is a general need to convert from an lvalue
to an rvalue. [<I>Note:</I> this conversion is deprecated.  See Annex
D
 [depr].  &#8212;<I>end note</I>] For the purpose of
ranking in overload resolution (13.3.3.1.1
 [over.ics.scs]), this
conversion is considered an array-to-pointer conversion followed by a
qualification conversion (4.4
 [conv.qual]).  [<I>Example:</I>
<TT>"abc"</TT> is converted to &#8220;pointer to <TT>const
char</TT>&#8221; as an array-to-pointer conversion, and then to
&#8220;pointer to <TT>char</TT>&#8221; as a qualification conversion.
&#8212;<I>end example</I>]</S>

</BLOCKQUOTE>

<LI><P>Delete the indicated text from the third sub-bullet of the
first bullet of paragraph 3 of 13.3.3.2
 [over.ics.rank]:</P></LI>

<UL><LI><P><TT>S1</TT> and <TT>S2</TT> differ only in their
qualification conversion and yield similar types <TT>T1</TT> and
<TT>T2</TT> (4.4
 [conv.qual]), respectively, and the
cv-qualification signature of type <TT>T1</TT> is a proper subset of
the cv-qualification signature of type <TT>T2</TT><S>, and <TT>S1</TT>
is not the deprecated string literal array-to-pointer conversion
(<TT>4.2</TT>)</S>. [<I>Example:</I> ...</P></LI></UL>

<LI><P>Delete the note from 15.1
 [except.throw] paragraph 3
as follows:</P></LI>

<BLOCKQUOTE>

A <I>throw-expression</I> initializes a temporary object, called the
<I>exception object</I>, the type of which is determined by removing
any top-level <I>cv-qualifier</I>s from the static type of the operand
of <TT>throw</TT> and adjusting the type from &#8220;array of
<TT>T</TT>&#8221; or &#8220;function returning <TT>T</TT>&#8221; to
&#8220;pointer to <TT>T</TT>&#8221; or &#8220;pointer to function
returning <TT>T</TT>&#8221;, respectively. <S>[<I>Note:</I> the temporary
object created for a <I>throw-expression</I> that is a string literal
is never of type <TT>char*</TT>, <TT>char16_t*</TT>,
<TT>char32_t*</TT>, or <TT>wchar_t*</TT>; that is, the special
conversions for string literals from the types &#8220;array of
<TT>const char</TT>&#8221;, &#8220;array of <TT>const
char16_t</TT>&#8221;, &#8220;array of <TT>const char32_t</TT>&#8221;,
and &#8220;array of <TT>const wchar_t</TT>&#8221; to the types
&#8220;pointer to <TT>char</TT>&#8221;, &#8220;pointer to
<TT>char16_t</TT>&#8221;, &#8220;pointer to <TT>char32_t</TT>&#8221;,
and &#8220;pointer to <TT>wchar_t</TT>&#8221;, respectively
(4.2
 [conv.array]), are never applied to a
<I>throw-expression</I>. &#8212;<I>end note</I>]</S> The temporary is
an lvalue...

</BLOCKQUOTE>

<LI><P>Change the discussion of 2.13.4
 [lex.string] in
C.1.1
 [diff.lex] as follows:</P></LI>

<BLOCKQUOTE>

<P>...</P>

<P><B>Difficulty of converting:</B> <S>Simple syntactic
transformation, because string literals can be converted to
<TT>char*</TT>; (4.2
 [conv.array]). The most common cases are
handled by a new but deprecated standard conversion:</S> <B>Semantic
transformation.</B></P>

<S>
<PRE>
    char* p = "abc";               //<SPAN STYLE="font-family:Times"><I> valid in C, deprecated in C++</I></SPAN>
    char* q = expr ? "abc" : "de"; //<SPAN STYLE="font-family:Times"><I> valid in C, invalid in C++</I></SPAN>
</PRE>
</S>

<P><B>How widely used:</B> <S>Programs that have a legitimate reason
to treat string literals as pointers to potentially modifiable memory
are probably rare.</S> <B>Seldom.</B></P>

</BLOCKQUOTE>

<LI><P>Delete D.4
 [depr.string]:</P></LI>

<BLOCKQUOTE>

<P><B><S>D.4   Implicit conversion from const strings</S></B></P>

<P><S>The implicit conversion from const to non-const qualification
for string literals (4.2
 [conv.array]) is deprecated.</S></P>

</BLOCKQUOTE>

</OL>

<P><B>Additional discussion (August, 2008):</B></P>



<P>The removal of this conversion for current string literals
would affect overload resolution for existing programs.  For
example,</P>

<PRE>
    struct S {
        S(const char*);
    };
    int f(char *);
    int f(X);
    int i = f("hello");
</PRE>

<P>If the conversion were removed, the result would be a quiet
change in behavior.  Another alternative to consider would be a
required diagnostic (without making the program ill-formed).</P>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>The CWG agreed that the deprecated conversion should continue
to apply to the literals to which it applied in C++ 2003.  Consensus
was not reached regarding whether it should apply only to those
literals or to all the new literals as well, although it was agreed
that the current situation in which it applies to some, but not all,
of the new literals is unacceptable.</P>

<BR><BR><HR><A NAME="685"></A><H4>685.
  
Integral promotion of enumeration ignores fixed underlying type
</H4><B>Section: </B>4.5&#160;
 [conv.prom]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alberto Ganesh Barbati
 &#160;&#160;&#160;

 <B>Date: </B>6 January, 2008<BR>


<P>According to 4.5
 [conv.prom] paragraph 2,</P>

<BLOCKQUOTE>

An rvalue of an unscoped enumeration type (7.2
 [dcl.enum]) can be converted to an rvalue of the first of the
following types that can represent all the values of the
enumeration (i.e. the values in the range <I>b<SUB>min</SUB></I>
to <I>b<SUB>max</SUB></I> as described in 7.2
 [dcl.enum]): <TT>int</TT>, <TT>unsigned int</TT>, <TT>long
int</TT>, <TT>unsigned long int</TT>, <TT>long long int</TT>, or
<TT>unsigned long long int</TT>.

</BLOCKQUOTE>

<P>This wording may have surprising behavior in this case:</P>

<PRE>
    enum E: long { e };

    void f(int);
    void f(long);

    void g() {
        f(e);    //<SPAN STYLE="font-family:Times"><I> Which </I></SPAN>f<SPAN STYLE="font-family:Times"><I> is called?</I></SPAN>
    }
</PRE>

<P>Intuitively,  as the programmer has explicitly expressed
preference for <TT>long</TT> as the underlying type, he/she might
expect <TT>f(long)</TT> to be called.  However, if <TT>long</TT>
and <TT>int</TT> happen to have the same size, then <TT>e</TT> is
promoted to <TT>int</TT> (as it is the first type in the list that
can represent all values of <TT>E</TT>) and <TT>f(int)</TT> is
called instead.</P>

<P>According to 7.2
 [dcl.enum] the underlying type of an
enumeration is always well-defined for both the fixed and the
non-fixed cases, so it makes sense simply to promote to the
underlying type unless such a type would itself require promotion.</P>

<P><U>Suggested resolution</U>:</P>

<P>In 4.5
 [conv.prom] paragraph 2, replace all the text
from &#8220;An rvalue of an unscoped enumeration type&#8221; through
the end of the paragraph with the following:</P>

<BLOCKQUOTE>

An rvalue of an unscoped enumeration type (7.2
 [dcl.enum])
is converted to an rvalue of its underlying type if it is different
from <TT>char16_t</TT>, <TT>char32_t</TT>, <TT>wchar_t</TT>, or has
integer conversion rank greater than or equal to <TT>int</TT>.
Otherwise, it is converted to an rvalue of the first of the following
types that can represent all the values of its underlying type:
<TT>int</TT>, <TT>unsigned int</TT>, <TT>long int</TT>,
<TT>unsigned long int</TT>, <TT>long long int</TT>, or
<TT>unsigned long long int</TT>.

</BLOCKQUOTE>

<P>(Note that this wording no longer needs to mention extended
integer types as special cases.)</P>

<P><B>Proposed resolution (August, 2008):</B></P>

<P>Move the following text from 4.5
 [conv.prom] paragraph
2 into a separate paragraph, making the indicated changes, and add
the following new pargraph after it:</P>

<BLOCKQUOTE>

<P>An rvalue of an unscoped enumeration type <B>whose underlying
type is not fixed</B> (7.2
 [dcl.enum]) can be converted
to an rvalue of the first of the following types that can
represent all the values of the enumeration (i.e. the values in
the range <I>b<SUB>min</SUB></I> to <I>b<SUB>max</SUB></I> as
described in 7.2
 [dcl.enum]): <TT>int</TT>,
<TT>unsigned int</TT>, <TT>long int</TT>, <TT>unsigned long
int</TT>, <TT>long long int</TT>, or <TT>unsigned long long
int</TT>.  If none of the types in that list can represent all
the values of the enumeration, an rvalue of an unscoped
enumeration type can be converted to an rvalue of the extended
integer type with lowest integer conversion rank (4.13
 [conv.rank]) greater than the rank of <TT>long long</TT> in
which all the values of the enumeration can be represented.  If
there are two such extended types, the signed one is chosen.</P>

<P>An rvalue of an unscoped enumeration type whose underlying
type is fixed (7.2
 [dcl.enum]) can be converted to an
rvalue of its underlying type. Moreover, if integral promotion
can be applied to its underlying type, an rvalue of an unscoped
enumeration type whose underlying type is fixed can also be
converted to an rvalue of the promoted underlying type.</P>

</BLOCKQUOTE>

<BR><BR><HR><A NAME="695"></A><H4>695.
  
Compile-time calculation errors in constexpr functions
</H4><B>Section: </B>5&#160;
 [expr]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>9 June, 2008<BR>


<P>Evaluating an expression like <TT>1/0</TT> is intended to produce
undefined behavior during the execution of a program but be ill-formed
at compile time.  The wording for this is in 5
 [expr]
paragraph 4:</P>

<BLOCKQUOTE>

If during the evaluation of an expression, the result is not
mathematically defined or not in the range of representable values for
its type, the behavior is undefined, unless such an expression appears
where an integral constant expression is required (5.19
 [expr.const]), in which case the program is ill-formed.

</BLOCKQUOTE>

<P>The formulation &#8220;appears where an integral constant
expression is required&#8221; is intended as an acceptable
Standardese circumlocution for &#8220;evaluated at compile time,&#8221;
a concept that is not directly defined by the Standard.  It is not
clear that this formulation adequately covers constexpr functions.</P>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>The CWG felt that the concept of &#8220;compile-time
evaluation&#8221; needs to be defined for use in discussing
constexpr functions.  There is a tension between wanting to
diagnose errors at compile time versus not diagnosing errors
that will not actually occur at runtime.  In this context, a
constexpr function might never be invoked, either in a
constant expression context or at runtime, although the
requirement that the expression in a constexpr function be a
potential constant expression could be interpreted as triggering
the provisions of 5
 [expr] paragraph 4.</P>

<P>There are also contexts in which it is not known in advance
whether an expression must be constant or not, notably in the
initializer of a const integer variable, where the nature of
the initializer determines whether the variable can be used in
constant expressions or not.  In such a case, it is not clear
whether an erroneous expression should be considered ill-formed
or simply non-constant (and thus subject to runtime undefined
behavior, if it is ever evaluated).  The consensus of the CWG
was that an expression like <TT>1/0</TT> should simply be
considered non-constant; any diagnostic would result from the
use of the expression in a context requiring a constant
expression.</P>

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

<P>See paper PL22.16/09-0016 = WG21 N2826.</P>

<BR><BR><HR><A NAME="342"></A><H4>342.
  
Terminology: "indirection" versus "dereference"
</H4><B>Section: </B>5.3&#160;
 [expr.unary]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jason Merrill
 &#160;&#160;&#160;

 <B>Date: </B>7 Oct 2001<BR>




<P>Split off from <A HREF="
     cwg_closed.html#315">issue 315</A>.</P>

<P>Incidentally, another thing that ought to be cleaned up is the inconsistent
use of "indirection" and "dereference".  We should pick one.</P>

<P><B>Proposed resolution (December, 2006):</B></P>

<OL>

<LI><P>Change 5.3.1
 [expr.unary.op] paragraph 1 as follows:</P></LI>

<BLOCKQUOTE>

The unary <TT>*</TT>
operator <S>performs <I>indirection</I></S> <B>dereferences a pointer
value</B>: the expression to which it is applied shall be a pointer...

</BLOCKQUOTE>

<LI><P>Change 8.3.4
 [dcl.array] paragraph 8 as follows:</P></LI>

<BLOCKQUOTE>

The <S>results are added and indirection applied</S> <B>values are
added and the result is dereferenced</B> to yield an array (of five
integers), which in turn is converted to a pointer to the first of the
integers.

</BLOCKQUOTE>

<LI><P>Change 8.3.5
 [dcl.fct] paragraph 9 as follows:</P></LI>

<BLOCKQUOTE>

The binding of <TT>*fpi(int)</TT> is <TT>*(fpi(int))</TT>, so the
declaration suggests, and the same construction in an expression
requires, the calling of a function <TT>fpi</TT>, and then <S>using
indirection through</S> <B>dereferencing</B> the (pointer) result
to yield an integer. In the declarator <TT>(*pif)(const char*, const
char*)</TT>, the extra parentheses are necessary to indicate that
<S>indirection through</S> <B>dereferencing</B> a pointer to a
function yields a function, which is then called.

</BLOCKQUOTE>

<LI><P>Change the index for <TT>*</TT> and &#8220;dereferencing&#8221;
no longer to refer to &#8220;indirection.&#8221;</P></LI>

</OL>

<P>[<I>Drafting note:</I> 26.5.9
 [template.indirect.array]
requires no change.  Many more places in the current wording use
&#8220;dereferencing&#8221; than &#8220;indirection.&#8221;]</P>

<BR><BR><HR><A NAME="292"></A><H4>292.
  
Deallocation on exception in <TT>new</TT> before arguments evaluated
</H4><B>Section: </B>5.3.4&#160;
 [expr.new]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Andrei Iltchenko
 &#160;&#160;&#160;

 <B>Date: </B>26 Jun 2001<BR>


<P>According to the C++ Standard section 5.3.4
 [expr.new]
paragraph 21 it is unspecified whether the allocation function is called before
evaluating the constructor arguments or after evaluating the
constructor arguments but before entering the constructor.</P>

<P>On top of that paragraph 17 of the same section insists that</P>
<BLOCKQUOTE>
If any
part of the object initialization described above [Footnote: This may
include evaluating a new-initializer and/or calling a constructor.]
terminates by throwing an exception and a suitable deallocation
function is found, the deallocation function is called to free the
memory in which the object was being constructed... If no unambiguous
matching deallocation function can be found, propagating the exception
does not cause the object's memory to be freed...
</BLOCKQUOTE>

<P>Now suppose we have:</P>
<OL>
<LI>
An implementation that always evaluates the constructor arguments
first (for a new-expression that creates an object of a class type and
has a new-initializer) and calls the allocation function afterwards.
</LI>
<LI>
A class like this:
<PRE>
    struct  copy_throw  {
       copy_throw(const copy_throw&amp;)
       {   throw  std::logic_error("Cannot copy!");   }
       copy_throw(long, copy_throw)
       {   }
       copy_throw()
       {   }
    };
</PRE>
</LI>
<LI>
And a piece of code that looks like the one below:
<PRE>
    int  main()
    try  {
       copy_throw   an_object,     /* undefined behaviour */
          * a_pointer = ::new copy_throw(0, an_object);
       return  0;
    }
    catch(const std::logic_error&amp;)
    {   }
</PRE>
</LI>
</OL>
<P>Here the new-expression '<TT>::new copy_throw(0, an_object)</TT>' throws an
exception when evaluating the constructor's arguments and before the
allocation function is called. However, 5.3.4
 [expr.new]
paragraph 17
prescribes that in such a case the implementation shall call the
deallocation function to free the memory in which the object was being
constructed, given that a matching deallocation function can be found.</P>

<P>So a call to the Standard library deallocation function '<TT>::operator
delete(void*)</TT>' shall be issued, but what argument is an implementation
supposed to supply to the deallocation function? As per
5.3.4
 [expr.new] paragraph 17 - the argument is the address
of the memory in
which the object was being constructed. Given that no memory has yet
been allocated for the object, this will qualify as using an invalid
pointer value, which is undefined behaviour by virtue of
3.7.4.2
 [basic.stc.dynamic.deallocation] paragraph 4.</P>

<P><B>Suggested resolution:</B></P>

<P>Change the first sentence of 5.3.4
 [expr.new] paragraph 17
to read:</P>
<BLOCKQUOTE>
If the memory for the object being created has already been
successfully allocated and any part of the object initialization
described above...
</BLOCKQUOTE>

<P><B>Proposed resolution (March, 2008):</B></P>

<P>Change 5.3.4
 [expr.new] paragraph 18 as follows:</P>

<BLOCKQUOTE>

If any part of the object initialization described above
[<I>Footnote:</I> ...]  terminates by throwing an exception<B>,
storage has been obtained for the object,</B> and a suitable
deallocation function can be found, the deallocation function is
called...

</BLOCKQUOTE>

<BR><BR><HR><A NAME="599"></A><H4>599.
  
Deleting a null function pointer
</H4><B>Section: </B>5.3.5&#160;
 [expr.delete]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Martin Sebor
 &#160;&#160;&#160;

 <B>Date: </B>3 October 2006<BR>


<P>The requirements for the operand of the <TT>delete</TT> operators are
given in 5.3.5
 [expr.delete] paragraph 2:</P>

<BLOCKQUOTE>

In either alternative, the value of the operand of <TT>delete</TT> may
be a null pointer value. If it is not a null pointer value, in the
first alternative (<I>delete object</I>), the value of the operand
of <TT>delete</TT> shall be a pointer to a non-array object or a
pointer to a subobject (1.8
 [intro.object]) representing a
base class of such an object (clause 10
 [class.derived]). If not,
the behavior is undefined. In the second alternative (<I>delete
array</I>), the value of the operand of <TT>delete</TT> shall be the
pointer value which resulted from a previous
array <I>new-expression</I>. If not, the behavior is undefined.

</BLOCKQUOTE>

<P>There are no restrictions on the type of a null pointer, only on
a pointer that is not null.  That seems wrong.</P>

<P><B>Proposed resolution (June, 2008):</B></P>

<P>Change 5.3.5
 [expr.delete] paragraph 1 as follows:</P>

<BLOCKQUOTE>

...The operand shall have a pointer <B>to object</B> type, or a
class type having a single non-explicit conversion function
(12.3.2
 [class.conv.fct]) to a pointer
<B>to object</B> type...

</BLOCKQUOTE>

<P><B>Proposed resolution (September, 2008):</B></P>

<OL><LI><P>Change 5.3.5
 [expr.delete] paragraph 1 as follows:</P></LI>

<BLOCKQUOTE>

...The operand shall have a pointer <B>to object</B> type, or a
class type having a single non-explicit conversion function
(12.3.2) to a pointer <B>to object</B> type. <B>[<I>Footnote:</I>
This implies that an object cannot be deleted using a pointer of
type <TT>void*</TT> because <TT>void</TT> is not an object type.
&#8212;<I>end footnote</I>]</B> ...

</BLOCKQUOTE>

<LI><P>Delete the footnote at the end of 5.3.5
 [expr.delete]
paragraph 3:</P></LI>

<BLOCKQUOTE>

...if the dynamic type of the object to be deleted differs from
its static type, the behavior is undefined. <S>[<I>Footnote:</I>
This implies that an object cannot be deleted using a pointer of
type <TT>void*</TT> because there are no objects of type
<TT>void</TT>. &#8212;<I>end footnote</I>]</S>

</BLOCKQUOTE>
</OL>

<BR><BR><HR><A NAME="236"></A><H4>236.
  
Explicit temporaries and integral constant expressions
</H4><B>Section: </B>5.19&#160;
 [expr.const]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>19 Jul 2000<BR>




<P>Does an explicit temporary of an integral type qualify as an
integral constant expression?  For instance,</P>

<PRE>
    void* p = int();    // well-formed?
</PRE>

<P>It would appear to be, since <TT>int()</TT> is an explicit type
conversion according to 5.2.3
 [expr.type.conv] (at least, it's
described in a section entitled "Explicit type conversion") and type
conversions to integral types are permitted in integral constant
expressions (5.19
 [expr.const]).  However, this reasoning is
somewhat tenuous, and some at least have argued otherwise.</P>

<P><B>Note (March, 2008):</B></P>

<P>This issue should be closed as NAD as a result of the rewrite of
5.19
 [expr.const] in conjunction with the constexpr proposal.</P>

<BR><BR><HR><A NAME="378"></A><H4>378.
  
Wording that says temporaries are declared
</H4><B>Section: </B>6.6&#160;
 [stmt.jump]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Gennaro Prota
 &#160;&#160;&#160;

 <B>Date: </B>07 September 2002<BR>


<P>Paragraph 6.6
 [stmt.jump] paragraph 2 of the standard says:</P>
<BLOCKQUOTE>
On exit from a scope (however accomplished), destructors
(12.4
 [class.dtor])
are called for all constructed objects with automatic storage
duration (3.7.3
 [basic.stc.auto])
(named objects or temporaries) that are declared
in that scope.
</BLOCKQUOTE>

<P>It refers to objects "that are declared" but the text in parenthesis
also mentions temporaries, which cannot be declared. I think that text
should be removed.</P>

<P>This is related to <A HREF="
     cwg_defects.html#276">issue 276</A>.</P>

<P><B>Proposed Resolution (November, 2006):</B></P>

<P>This issue is resolved by the resolution of
<A HREF="
     cwg_defects.html#276">issue 276</A>.</P>

<BR><BR><HR><A NAME="699"></A><H4>699.
  
Must constexpr member functions be defined in the class <I>member-specification</I>?
</H4><B>Section: </B>7.1.5&#160;
 [dcl.constexpr]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>26 June, 2008<BR>




<P>According to 7.1.5
 [dcl.constexpr] paragraph 1,</P>

<BLOCKQUOTE>

The <TT>constexpr</TT> specifier shall be applied only to the
definition of an object, function, or function template, or to the
declaration of a static data member of a literal type (3.9
 [basic.types]).

</BLOCKQUOTE>

<P>As a result, a constexpr member function cannot be simply declared
in the class <I>member-specification</I> and defined later; it must
be defined in its initial declaration.</P>

<P>This restriction was not part of the initial proposal but was added
during the CWG review.  However, the original intent is still visible
in some of the wording in 7.1.5
 [dcl.constexpr].  For example,
paragraph 2 refers to applying the <TT>constexpr</TT> specifier to the
&#8220;declaration&#8221; and not the &#8220;definition&#8221; of a
function or constructor.  Although that is formally correct, as
definitions are also declarations, it could be confusing.  Also, the
example in paragraph 6 reads,</P>

<PRE>
    class debug_flag {
    public:
      explicit debug_flag(bool);
      constexpr bool is_on();    //<SPAN STYLE="font-family:Times"><I> error: </I></SPAN>debug_flag<SPAN STYLE="font-family:Times"><I> not literal type</I></SPAN>
      ...
</PRE>

<P>when the proximate error is that <TT>is_on</TT> is only declared,
not defined.  There are also many occurrences of the <TT>constexpr</TT>
specifier in the library clauses where the member function is only
declared, not defined.</P>

<P>It's not clear how much simplification is gained by this restriction.
There are reasons for defining ordinary inline functions outside the
class <I>member-specification</I> (reducing the size and complexity of
the class definition, separating interface from implementation, making
the editing task easier if program evolution results in an inline
function being made non-inline, etc.) that would presumably apply to
constexpr member functions as well.  It seems feasible to allow
separate declaration and definition of a constexpr function; it would
simply not be permitted to use it in a constant expression before the
definition is seen (although it could presumably still be used in
non-constant expressions in that region, like an ordinary inline
function).</P>

<P>If the prohibition were relaxed to allow separate declaration and
definition of constexpr member functions, some questions would need to
be answered, such as whether the <TT>constexpr</TT> specifier must
appear on both declaration and definition (the <TT>inline</TT>
specifier need not). If it can be omitted in one or the other, there's
a usability issue regarding the fact that <TT>constexpr</TT> implies
<TT>const</TT>; the <TT>const</TT> qualifier would need to be
specified explicitly in the declaration in which <TT>constexpr</TT>
was omitted.</P>

<P>If the current restriction is kept, the library clauses should
state in an introduction that a non-defining declaration of a
constexpr member function should be considered &#8220;for exposition
only&#8221; and not literal code.</P>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>In addition to the original issues described above, the
question has arisen whether recursive constexpr functions
are or should be permitted.  Although they were originally
desired by the proposers of the feature, they were prohibited
out of an abundance of caution.  However, the wording that
specified the prohibition was changed during the review
process, inadvertently permitting them.</P>

<P>The CWG felt that there are sufficient use cases for
recursion that it should not be forbidden (although a new
minimum for recursion depth should be added to Annex
B
 [implimits]).  If mutual recursion is to be
allowed, forward declaration of constexpr functions must
also be permitted (answering the original question in this
issue).  A call to an undefined constexpr function in the
body of a constexpr function should be diagnosed when the
outer constexpr function is invoked in a context requiring
a constant expression; in all other contexts, a call to
an undefined constexpr function should be treated as a
normal runtime function call, just as if it had been invoked
with non-constant arguments.</P>

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

<P>See paper PL22.16/09-0016 = WG21 N2826.</P>

<BR><BR><HR><A NAME="539"></A><H4>539.
  
Constraints on <I>type-specifier-seq</I>
</H4><B>Section: </B>7.1.6&#160;
 [dcl.type]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>5 October 2005<BR>


<P>The constraints on <I>type-specifier</I>s given in
7.1.6
 [dcl.type] paragraphs 2 and 3 (at most one
<I>type-specifier</I> except as specified, at least one
<I>type-specifier</I>, no redundant cv-qualifiers) are couched in
terms of <I>decl-specifier-seq</I>s and <I>declaration</I>s.  However,
they should also apply to constructs that are not syntactically
<I>declaration</I>s and that are defined to use
<I>type-specifier-seq</I>s, including 5.3.4
 [expr.new],
6.6
 [stmt.jump], 8.1
 [dcl.name], and
12.3.2
 [class.conv.fct].</P>

<P><B>Proposed resolution (March, 2008):</B></P>

<P>Change 7.1.6
 [dcl.type] paragraph 3 as follows:</P>

<BLOCKQUOTE>

<S>At</S> <B>In a complete <I>type-specifier-seq</I> or in a
complete <I>decl-specifier-seq</I> of a declaration, at</B> least
one <I>type-specifier</I> that is not a
<I>cv-qualifier</I> <S>is required in a declaration</S> <B>shall
appear</B> unless <S>it</S> <B>the declaration</B> declares a
constructor, destructor or conversion function.

</BLOCKQUOTE>

<P><I>(Note: paper N2546, voted into the Working Draft in February,
2008, addresses part of this issue.)</I></P>

<BR><BR><HR><A NAME="482"></A><H4>482.
  
Qualified declarators in redeclarations
</H4><B>Section: </B>8.3&#160;
 [dcl.meaning]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>03 Nov 2004<BR>


<P>According to 8.3
 [dcl.meaning] paragraph 1,</P>

<BLOCKQUOTE>

A <I>declarator-id</I> shall not be qualified except for the
definition of a member function (9.3
 [class.mfct]) or
static data member (9.4
 [class.static]) outside of its
class, the definition or explicit instantiation of a function or
variable member of a namespace outside of its namespace, or the
definition of a previously declared explicit specialization
outside of its namespace, or the declaration of a friend function
that is a member of another class or namespace (11.4
 [class.friend]). When the <I>declarator-id</I> is qualified, the
declaration shall refer to a previously declared member of the
class or namespace to which the qualifier refers...

</BLOCKQUOTE>

<P>This restriction prohibits examples like the following:</P>

<PRE>
    void f();
    void ::f();        // error: qualified declarator

    namespace N {
      void f();
      void N::f() { }  // error: qualified declarator
    }
</PRE>

<P>There doesn't seem to be any good reason for disallowing such
declarations, and a number of implementations accept them in
spite of the Standard's prohibition.  Should the Standard be
changed to allow them?</P>

<P><B>Notes from the April, 2006 meeting:</B></P>

<P>In discussing <A HREF="
     cwg_closed.html#548">issue 548</A>, the CWG agreed
that the prohibition of qualified declarators inside their namespace
should be removed.</P>

<P><B>Proposed resolution (October, 2006):</B></P>

<P>Remove the indicated words from 8.3
 [dcl.meaning]
paragraph 1:</P>

<BLOCKQUOTE>

...An <I>unqualified-id</I> occurring in a <I>declarator-id</I> shall
be a simple <I>identifier</I> except for the declaration of some
special functions (12.3
 [class.conv], 12.4
 [class.dtor], 13.5
 [over.oper]) and for the declaration of
template specializations or partial specializations (). <S>A <I>declarator-id</I> shall not be qualified
except for the definition of a member function (9.3
 [class.mfct]) or static data member (9.4
 [class.static])
outside of its class, the definition or explicit instantiation of a
function or variable member of a namespace outside of its namespace,
or the definition of a previously declared explicit specialization
outside of its namespace, or the declaration of a friend function that
is a member of another class or namespace (11.4
 [class.friend]).</S> When the <I>declarator-id</I> is qualified, the
declaration shall refer to a previously declared member of the class
or namespace to which the qualifier refers, and the member shall not
have been introduced by a <I>using-declaration</I> in the scope of the
class or namespace nominated by the <I>nested-name-specifier</I> of
the <I>declarator-id</I>...

</BLOCKQUOTE>

<P>[<I>Drafting note:</I> The omission of &#8220;outside of its
class&#8221; here does not give permission for redeclaration of
class members; that is still prohibited by 9.2
 [class.mem]
paragraph 1.  The removal of the enumeration of the kinds of
declarations in which a <I>qualified-id</I> can appear does allow
a <TT>typedef</TT> declaration to use a <I>qualified-id</I>, which
was not permitted before; if that is undesirable, the prohibition can
be reinstated here.]</P>

<BR><BR><HR><A NAME="547"></A><H4>547.
  
Partial specialization on member function types
</H4><B>Section: </B>8.3.5&#160;
 [dcl.fct]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Peter Dimov
 &#160;&#160;&#160;

 <B>Date: </B>04 November 2005<BR>




<P>The following example appears to be well-formed, with the partial
specialization matching the type of <TT>Y::f()</TT>, even though it
is rejected by many compilers:</P>

<PRE>
    template&lt;class T&gt; struct X;

    template&lt;class R&gt; struct X&lt; R() &gt; {
    };

    template&lt;class F, class T&gt; void test(F T::* pmf) {
        X&lt;F&gt; x;
    }

    struct Y {
        void f() {
        }
    };

    int main() {
        test( &amp;Y::f );
    }
</PRE>

<P>However, 8.3.5
 [dcl.fct] paragraph 4 says,</P>

<BLOCKQUOTE>

A <I>cv-qualifier-seq</I> shall only be part of the function type for
a non-static member function, the function type to which a pointer to
member refers, or the top-level function type of a function typedef
declaration. The effect of a <I>cv-qualifier-seq</I> in a function
declarator is not the same as adding cv-qualification on top of the
function type. In the latter case, the cv-qualifiers are ignored.

</BLOCKQUOTE>

<P>This specification makes it impossible to write a partial
specialization for a <TT>const</TT> member function:</P>

<PRE>
    template&lt;class R&gt; struct X&lt;R() const&gt; {
    };
</PRE>

<P>A template argument is not one of the permitted contexts for
cv-qualification of a function type.  This restriction should be
removed.</P>

<P><B>Notes from the April, 2006 meeting:</B></P>

<P>During the meeting the CWG was of the opinion that the
&#8220;<TT>R() const</TT>&#8221; specialization would not match
the const member function even if it were allowed and so classified
the issue as NAD.  Questions have been raised since the meeting,
however, suggesting that the template argument in the partial
specialization would, in fact, match the type of a const member
function (see, for example, the very similar usage via typedefs
in 9.3
 [class.mfct] paragraph 9).  The issue is thus being
left open for renewed discussion at the next meeting.</P>

<P><B>Proposed resolution (June, 2008):</B></P>

<P>Change 8.3.5
 [dcl.fct] paragraph 7 as follows:</P>

<BLOCKQUOTE>

A <I>cv-qualifier-seq</I> shall only be part of the function type for a
non-static member function, the function type to which a pointer to
member refers, <S>or</S> the top-level function type of a function typedef
declaration<B>, or the top-level function type of a <I>type-id</I> that is a
<I>template-argument</I> for a type <I>template-parameter</I></B>. The
effect... A <I>ref-qualifier</I> shall only be part of the function type for
a non-static member function, the function type to which a pointer to
member refers, <S>or</S> the top-level function type of a function typedef
declaration<B>, or the top-level function type of a <I>type-id</I> that is a
<I>template-argument</I> for a type <I>template-parameter</I></B>. The
return type...

</BLOCKQUOTE>

<BR><BR><HR><A NAME="694"></A><H4>694.
  
Zero- and value-initialization of union objects
</H4><B>Section: </B>8.5&#160;
 [dcl.init]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Clark Nelson
 &#160;&#160;&#160;

 <B>Date: </B>14 May, 2008<BR>


<P>The C committee is considering changing the definition of
zero-initialization of unions to guarantee that the bytes of the
entire union are set to zero before assigning 0, converted to the
appropriate type, to the first member.  The argument (summarized
<A href="http://www.open-std.org/jtc1/sc22/wg14/11416">here</A>)
is for backward compatibility.  The C++ Committee may want to
consider the same change.</P>

<P><B>Proposed resolution (August, 2008):</B></P>

<P>Change bullet 4 of 8.5
 [dcl.init] paragraph 5 as
follows:</P>

<UL><LI>if T is a union type, <B>the object representation of <TT>T</TT>
(3.9
 [basic.types]) is zero-initialized, after which</B>
the object's first named <B>non-static</B> data member
<S>[<I>Footnote:</I> This member must not be static, by virtue of the
requirements in 9.5
 [class.union]. &#8212;<I>end
footnote</I>]</S> is zero-initialized;</LI></UL>

<P><I>[Drafting notes: Ask a C liaison about the progress of WG14
paper N1311, which deals with this issue.  Since the adoption of
WG21 paper N2544, unions may have static data members, hence the
change to refer to the first non-static data member and the
deletion of the footnote.]</I></P>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>It was observed that padding bytes in structs are
zero-initialized in C, so if we are changing the treatment of
unions in this way we should consider adding the C behavior for
padding bytes at the same time.  In particular, using
<TT>memcmp</TT> to compare structs only works reliably if the
padding bytes are zero-initialized.</P>

<BR><BR><HR><A NAME="355"></A><H4>355.
  
Global-scope <TT>::</TT> in <I>nested-name-specifier</I>
</H4><B>Section: </B>9&#160;
 [class]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Clark Nelson
 &#160;&#160;&#160;

 <B>Date: </B>16 May 2002<BR>




<P>
In looking at a large handful of core issues related to
<I>elaborated-type-specifier</I>s and the naming of classes in general, I
discovered an odd fact. It turns out that there is exactly one place in the
grammar where <I>nested-name-specifier</I>
is not immediately preceded by "<TT>::</TT><SUB><I>opt</I></SUB>":
in <I>class-head</I>, which is used only for class definitions. So technically,
this example is ill-formed, and should evoke a syntax error:
</P>
<PRE>
  struct A;
  struct ::A { };
</PRE>
<P>
However, all of EDG, GCC and Microsoft's compiler accept it without a qualm.
In fact, I couldn't get any of them to even warn about it.</P>

<P><B>Suggested resolution:</B></P>

<P>It would simplify the grammar, and apparently better reflect existing
practice, to factor the global-scope operator into the rule for
<I>nested-name-specifier</I>.</P>

<P><B>Proposed resolution (November, 2006):</B></P>

<OL><LI><P>In 3.4.3
 [basic.lookup.qual] paragraph 6, change the
grammar snippet as follows:</P>

<P><UL><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier<SUB>opt</SUB> class-name </I><TT>:: ~</TT><I> class-name</I></UL></P>
</LI>

<LI><P>Delete 5.1
 [expr.prim] paragraph 4 (&#8220;The operator
<TT>::</TT> followed by...&#8221;).  <I>[Drafting note: It's covered by
paragraph 8 (type, lvalue-ness, member-ness, reference to
3.4.3.2
 [namespace.qual]) and 3.4.3.2
 [namespace.qual]
(qualified lookup for namespace members).]</I></P>
</LI>

<LI><P>Change the grammar in 5.1
 [expr.prim] paragraph 7 as
follows (deleting the <TT>::</TT> forms from <I>qualified-id</I> and
adding <TT>::</TT> as a new production for <I>nested-name-specifier</I>):</P>

<P><UL><I>qualified-id:</I>
<UL><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier </I><TT>template</TT><I><SUB>opt</SUB> unqualified-id</I></UL>
<UL><S><TT>::</TT><I> identifier</I></S></UL>
<UL><S><TT>::</TT><I> operator-function-id</I></S></UL>
<UL><S><TT>::</TT><I> template-id</I></S></UL>
<I>nested-name-specifier:</I>
<UL><B><TT>::</TT></B></UL>
<UL><I>type-name </I><TT>::</TT></UL>
<UL><I>namespace-name </I><TT>::</TT></UL>
<UL><I>nested-name-specifier identifier </I><TT>::</TT></UL>
<UL><I>nested-name-specifier </I><TT>template</TT><I><SUB>opt</SUB> simple-template-id </I><TT>::</TT></UL></UL></P>
</LI>

<LI><P>Change 5.1
 [expr.prim] paragraph 8 as follows:</P>

<BLOCKQUOTE>

A nested-name-specifier that <S>names</S> <B>designates</B> a
namespace (7.3
 [basic.namespace]), followed by the name of a member
of that namespace...

</BLOCKQUOTE>
</LI>

<LI><P>Change 5.1
 [expr.prim] paragraph 10 as follows:</P>

<BLOCKQUOTE>

In a <I>qualified-id</I>, if
the <S><I>id-expression</I></S> <B><I>unqualified-id</I></B> is
a <I>conversion-function-id</I>...

</BLOCKQUOTE>
</LI>

<LI><P>In 5.2
 [expr.post] paragraph 1, change the grammar
as follows:</P>

<P><UL><I>pseudo-destructor-name:</I>
<UL><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier<SUB>opt</SUB> type-name </I><TT>:: ~</TT><I> type-name</I></UL>
<UL><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier </I><TT>template</TT><I> simple-template-id </I><TT>:: ~</TT><I> type-name</I></UL>
<UL><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier<SUB>opt</SUB> </I><TT>~</TT><I> type-name</I></UL></UL></P>
</LI>

<LI><P>In 5.2.4
 [expr.pseudo] paragraph 2, change the grammar snippet
as follows:</P>

<P><UL><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier<SUB>opt</SUB> type-name </I><TT>:: ~</TT><I> type-name</I></UL></P>
</LI>

<LI><P>In 7.1.6.2
 [dcl.type.simple] paragraph 1, change the grammar
as follows:</P>

<P><UL><I>simple-type-specifier:</I>
<UL><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier<SUB>opt</SUB> type-name</I></UL>
<UL><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier </I><TT>template</TT><I> simple-template-id</I></UL>
<UL><TT>...</TT></UL></UL></P>
</LI>

<LI><P>In 7.1.6.3
 [dcl.type.elab] before paragraph 1, change the
grammar as follows:</P>

<P><UL><I>elaborated-type-specifier:</I>
<UL><I>class-key </I><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier<SUB>opt</SUB> identifier</I></UL>
<UL><I>class-key </I><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier<SUB>opt</SUB> </I><TT>template</TT><I><SUB>opt</SUB> simple-template-id</I></UL>
<UL><I>enum-key </I><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier<SUB>opt</SUB> identifier</I></UL></UL></P>
</LI>

<LI><P>In 7.1.6.3
 [dcl.type.elab] paragraph 1, change the grammar
snippet as follows:</P>

<P><UL><I>class-key identifier </I><TT>;</TT><BR>
<S><TT>friend</TT><I> class-key </I><TT>::</TT><I><SUB>opt</SUB> identifier </I><TT>;</TT></S><BR>
<TT>friend</TT><I> class-key </I><TT>::</TT><I><SUB>opt</SUB> simple-template-id </I><TT>;</TT><BR>
<TT>friend</TT><I> class-key </I><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier identifier </I><TT>;</TT><BR>
<TT>friend</TT><I> class-key </I><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier </I><TT>template</TT><I><SUB>opt</SUB> simple-template-id </I><TT>;</TT></UL></P>
</LI>

<LI><P>In 7.3.2
 [namespace.alias] paragraph 1, change the grammar as
follows:</P>

<P><UL><I>qualified-namespace-specifier:</I>
<UL><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier<SUB>opt</SUB> namespace-name</I></UL></UL></P>
</LI>

<LI><P>In 7.3.3
 [namespace.udecl] paragraph 1, change the grammar as
follows:</P>

<P><UL><I>using-declaration:</I>
<UL><TT>using typename</TT><I><SUB>opt</SUB> </I><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier unqualified-id </I><TT>;</TT></UL>
<UL><S><TT>using ::</TT><I> unqualified-id </I><TT>;</TT></S></UL></UL></P>
</LI>

<LI><P>In 7.3.4
 [namespace.udir] before paragraph 1, change the grammar
as follows:</P>

<P><UL><I>using-directive:</I>
<UL><TT>using namespace </TT><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier<SUB>opt</SUB> namespace-name </I><TT>;</TT></UL></UL></P>
</LI>

<LI><P>In 8
 [dcl.decl] paragraph 4, change the grammar as
follows:</P>

<P><UL><I>ptr-operator:</I>
<UL><TT>*</TT><I> cv-qualifier-seq<SUB>opt</SUB></I></UL>
<UL><TT>&amp;</TT></UL>
<UL><TT>&amp;&amp;</TT></UL>
<UL><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier </I><TT>*</TT><I> cv-qualifier-seq<SUB>opt</SUB></I></UL>
<TT>...</TT><BR>
<I>declarator-id:</I>
<UL><TT>...</TT><I><SUB>opt</SUB> id-expression</I></UL>
<UL><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier<SUB>opt</SUB> class-name</I></UL></UL></P>
</LI>

<LI><P>In 8.3.3
 [dcl.mptr] paragraph 1, change the grammar
snippet as follows:</P>

<P><UL><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier </I><TT>*</TT><I> cv-qualifier-seq<SUB>opt</SUB> D1</I></UL></P>
</LI>

<LI><P>In 9.2
 [class.mem] before paragraph 1, change the grammar
as follows:</P>

<P><UL><I>member-declaration:</I>
<UL><I>decl-specifier-seq<SUB>opt</SUB> member-declarator-list<SUB>opt</SUB> </I><TT>;</TT></UL>
<UL><I>function-definition </I><TT>;</TT><I><SUB>opt</SUB></I></UL>
<UL><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier </I><TT>template</TT><I><SUB>opt</SUB> unqualified-id </I><TT>;</TT></UL>
<UL><I>using-declaration</I></UL>
<UL><I>static_assert-declaration</I></UL>
<UL><I>template-declaration</I></UL></UL></P>
</LI>

<LI><P>In 10
 [class.derived] paragraph 1, change the grammar as
follows:</P>

<P><UL><I>base-specifier:</I>
<UL><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier<SUB>opt</SUB> class-name</I></UL>
<UL><TT>virtual</TT><I> access-specifier<SUB>opt</SUB> </I><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier<SUB>opt</SUB> class-name</I></UL>
<UL><I>access-specifier </I><TT>virtual</TT><I><SUB>opt</SUB> </I><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier<SUB>opt</SUB> class-name</I></UL></UL></P>
</LI>

<LI><P>In 12.6.2
 [class.base.init] paragraph 1, change the grammar as
follows:</P>

<P><UL><I>mem-initializer-id:</I>
<UL><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier<SUB>opt</SUB> class-name</I></UL>
<UL><I>identifier</I></UL></UL></P>
</LI>

<LI><P>In 14.6
 [temp.res] paragraph 3, change the grammar as
follows:</P>

<P><UL><I>typename-specifier:</I>
<UL><TT>typename </TT><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier identifier</I></UL>
<UL><TT>typename </TT><S><TT>::</TT><I><SUB>opt</SUB></I></S> <I>nested-name-specifier </I><TT>template</TT><I><SUB>opt</SUB> simple-template-id</I></UL></UL></P>
</LI>
</OL>

<P><I>[Drafting notes: gcc 4.1.1 rejects the example in the issue
description. I still think it's a good idea to make the grammar more
uniform, and there ought to be nothing special about the global scope
operator. However, there is a slight change in effective grammar with
these modification: all places that require a non-optional
nested-name-specifier used to required at least one named level of
nesting. With these changes, "::" is a valid nested-name-specifier
(that denotes the global scope). Any such use needed to protect
against non-class (i.e. namespace) scopes in its semantic description
anyway, which also covers the "::" case.]</I></P>

<BR><BR><HR><A NAME="512"></A><H4>512.
  
Union members with user-declared non-default constructors
</H4><B>Section: </B>9.5&#160;
 [class.union]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alisdair Meredith
 &#160;&#160;&#160;

 <B>Date: </B>19 Mar 2005<BR>


<P>Can a member of a union be of a class that has a user-declared
non-default constructor?  The restrictions on union membership in
9.5
 [class.union] paragraph 1 only mention default and
copy constructors:</P>

<BLOCKQUOTE>

An object of a class with a non-trivial default constructor
(12.1
 [class.ctor]), a non-trivial copy constructor
(12.8
 [class.copy]), a non-trivial destructor (12.4
 [class.dtor]), or a non-trivial copy assignment operator
(13.5.3
 [over.ass], 12.8
 [class.copy]) cannot be
a member of a union...

</BLOCKQUOTE>

<P>(12.1
 [class.ctor] paragraph 11 does say,
&#8220;a non-trivial constructor,&#8221; but it's not clear whether
that was intended to refer only to default and copy constructors
or to any user-declared constructor.  For example,
12.2
 [class.temporary] paragraph 3 also speaks of a
&#8220;non-trivial constructor,&#8221; but the cross-references
there make it clear that only default and copy constructors are
in view.)</P>

<P><B>Note (March, 2008):</B></P>

<P>This issue was resolved by the adoption of paper J16/08-0054 =
WG21 N2544 (&#8220;Unrestricted Unions&#8221;) at the Bellevue meeting.</P>

<BR><BR><HR><A NAME="347"></A><H4>347.
  
Use of derived class name in defining base class nested class
</H4><B>Section: </B>9.7&#160;
 [class.nest]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jason Shirk
 &#160;&#160;&#160;

 <B>Date: </B>21 March 2002<BR>




<P>9.3
 [class.mfct] paragraph 5 says this about member
functions defined lexically outside the class:</P>
<BLOCKQUOTE>
the member function name shall be qualified by its class name using
the :: operator
</BLOCKQUOTE>

<P>9.4.2
 [class.static.data] paragraph 2 says this about static
data members:</P>
<BLOCKQUOTE>
In the definition at namespace scope, the name of the static data
member shall be qualified by its class name using the :: operator
</BLOCKQUOTE>

<P>I would have expected similar wording in 9.7
 [class.nest]
paragraph 3 for nested classes. Without such wording, the following
seems to be legal (and is allowed by all the compilers I have):</P>
<PRE>
  struct base {
    struct nested;
  };

  struct derived : base {};
  struct derived::nested {};
</PRE>

<P>Is this just an oversight, or is there some rationale for this behavior?</P>

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

<P>The existing wording in 9
 [class] paragraph 10 makes the
example ill-formed:</P>

<BLOCKQUOTE>

If a <I>class-head</I> contains a <I>nested-name-specifier</I>, the
<I>class-specifier</I> shall refer to a class that was previously
declared directly in the class or namespace to which
the <I>nested-name-specifier</I> refers (i.e., neither inherited nor
introduced by a <I>using-declaration</I>), and
the <I>class-specifier</I> shall appear in a namespace enclosing the
previous declaration.

</BLOCKQUOTE>

<P>The issue should be closed as NAD.</P>

<BR><BR><HR><A NAME="696"></A><H4>696.
  
Use of block-scope constants in local classes
</H4><B>Section: </B>9.8&#160;
 [class.local]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Adamczyk
 &#160;&#160;&#160;

 <B>Date: </B>29 May, 2008<BR>


<P>According to 9.8
 [class.local] paragraph 1,</P>

<BLOCKQUOTE>

Declarations in a local class can use only type names, static variables,
extern variables and functions, and enumerators from the enclosing scope.

</BLOCKQUOTE>

<P>This would presumably make both of the members of <TT>S2</TT> below
ill-formed:</P>

<PRE>
    void test () {
      const int local_const = 7;
      struct S2 {
        int member:local_const;
        void f() { int j = local_const; }
      };
    }
</PRE>

<P>Should there be an exception to this rule for constant values?
Current implementations seem to accept the reference to
<TT>local_const</TT> in the bit-field declaration but not in the
member function definition.  Should they be the same or different?</P>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>The CWG agreed that both uses of <TT>local_const</TT> in the
example above should be accepted.  The intent of the restriction
was to avoid the need to pass a frame pointer into local class
member functions, so uses of local const variables as values
should be permitted.</P>

<P><B>Proposed resolution (September, 2008):</B></P>

<P>Change 9.8
 [class.local] paragraph 1 as follows:</P>

<BLOCKQUOTE>

...Declarations in a local class <S>can use only type names, static
variables, <TT>extern</TT> variables and functions, and
enumerators</S> <B>shall not refer to the name of an automatic
variable or reference</B> from the enclosing scope<B>, unless the
variable or reference satisfies the requirements for appearing in a
constant expression (5.19
 [expr.const]) and the
lvalue-to-rvalue conversion (4.1
 [conv.lval]) is immediately
applied</B>. [<I>Example:</I>

<PRE>
  int x;
  void f() {
    static int s ;
    int x;
    extern int g();
    <B>const int c = 42;</B>
    struct local {
      int g() { return x; }     //<SPAN STYLE="font-family:Times"><I> error: </I></SPAN>x<SPAN STYLE="font-family:Times"><I> has automatic storage duration</I></SPAN>
      int h() { return s; }     //<SPAN STYLE="font-family:Times"><I> OK</I></SPAN>
      int k() { return ::x; }   //<SPAN STYLE="font-family:Times"><I> OK</I></SPAN>
      int l() { return g(); }   //<SPAN STYLE="font-family:Times"><I> OK</I></SPAN>
      <B>int m() { return c; }     //<SPAN STYLE="font-family:Times"><I> OK</I></SPAN></B>
    };
  }

  local* p = 0;                 //<SPAN STYLE="font-family:Times"><I> error: </I></SPAN>local<SPAN STYLE="font-family:Times"><I> not in scope</I></SPAN>
</PRE>

&#8212;<I>end example</I>]

</BLOCKQUOTE>

<BR><BR><HR><A NAME="608"></A><H4>608.
  
Determining the final overrider of a virtual function
</H4><B>Section: </B>10.3&#160;
 [class.virtual]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>7 December 2006<BR>


<P>According to 10.3
 [class.virtual] paragraph 2:</P>

<BLOCKQUOTE>

Then in any well-formed class, for each virtual function declared
in that class or any of its direct or indirect base classes there
is a unique <I>final overrider</I> that overrides that function
and every other overrider of that function. The rules for member
lookup (10.2
 [class.member.lookup]) are used to determine the
final overrider for a virtual function in the scope of a derived
class but ignoring names introduced by <I>using-declaration</I>s.

</BLOCKQUOTE>

<P>I think that description is wrong on at least a couple of
counts.  First, consider the following example:</P>

<PRE>
    struct A { virtual void f(); };
    struct B: A { };
    struct C: A { void f(); };
    struct D: B, C { };
</PRE>

<P>What is the &#8220;unique final overrider&#8221; of
<TT>A::f()</TT> in <TT>D</TT>?  According to
10.3
 [class.virtual] paragraph 2, we determine that by
looking up <TT>f</TT> in <TT>D</TT> using the lookup rules in
10.2
 [class.member.lookup].  However, that lookup determines that
<TT>f</TT> in <TT>D</TT> is ambiguous, so there is no
&#8220;unique final overrider&#8221; of <TT>A::f()</TT> in
<TT>D</TT>.  Consequently, because &#8220;any well-formed
class&#8221; must have such an overrider, <TT>D</TT> must be
ill-formed.</P>

<P>Of course, we all know that <TT>D</TT> is <I>not</I>
ill-formed.  In fact, 10.3
 [class.virtual] paragraph 10
contains an example that illustrates exactly this point:</P>

<BLOCKQUOTE>

<PRE>
struct A {
    virtual void f();
};
struct B1 : A {     //<SPAN STYLE="font-family:Times"><I> note non-virtual derivation</I></SPAN>
    void f();
};
struct B2 : A {
    void f();
};
struct D : B1, B2 { //<SPAN STYLE="font-family:Times"><I> </I></SPAN>D<SPAN STYLE="font-family:Times"><I> has two separate </I></SPAN>A<SPAN STYLE="font-family:Times"><I> subobjects</I></SPAN>
};
</PRE>

<P>In class <TT>D</TT> above there are two occurrences of
class <TT>A</TT> and hence two occurrences of the virtual member
function <TT>A::f</TT>.  The final overrider of <TT>B1::A::f</TT>
is <TT>B1::f</TT> and the final overrider of <TT>B2::A::f</TT>
is <TT>B2::f</TT>.</P>

</BLOCKQUOTE>

<P>It appears that the requirement for a &#8220;unique final
overrider&#8221; in 10.3
 [class.virtual] paragraph 2 needs
to say something about sub-objects.  Whatever that
&#8220;something&#8221; is, you can't just say &#8220;look up the
name in the derived class using 10.2
 [class.member.lookup].&#8221;</P>

<P>There's another problem with using the 10.2
 [class.member.lookup]
lookup to specify the final overrider: name lookup just looks up the
name, while the overriding relationship is based not only on the name
but on a matching parameter-type-list and cv-qualification.  To
illustrate this point:</P>

<PRE>
    struct X {
        virtual void f();
    };
    struct Y: X {
        void f(int);
    };
    struct Z: Y { };
</PRE>

<P>What is the &#8220;unique final overrider&#8221; of
<TT>X::f()</TT> in <TT>A</TT>?  Again, 10.3
 [class.virtual]
paragraph 2 says you're supposed to look up <TT>f</TT> in
<TT>Z</TT> to find it; however, what you find is
<TT>Y::f(int)</TT>, not <TT>X::f()</TT>, and that's clearly
wrong.</P>

<P><B>Proposed Resolution (December, 2006):</B></P>

<P>Change 10.3
 [class.virtual] paragraph 2 as follows:</P>

<BLOCKQUOTE>

<S>Then in any well-formed class, for each virtual function declared in
that class or any of its direct or indirect base classes there is a
unique <I>final overrider</I> that overrides that function and every
other overrider of that function. The rules for member lookup
(10.2
 [class.member.lookup]) are used to determine the final overrider
for a virtual function in the scope of a derived class but ignoring
names introduced by <I>using-declaration</I> s.</S> <B>A virtual
member function <TT>vf</TT> of a class <TT>C</TT> is a <I>final
overrider</I> unless the most derived class (1.8
 [intro.object])
of which <TT>C</TT> is a base class (if any) declares or inherits
another member function that overrides <TT>vf</TT>.  In a derived class,
if a virtual member function of a base class subobject has more than
one final overrider, the program is ill-formed.</B>

</BLOCKQUOTE>

<BR><BR><HR><A NAME="462"></A><H4>462.
  
Lifetime of temporaries bound to comma expressions
</H4><B>Section: </B>12.2&#160;
 [class.temporary]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Adamczyk
 &#160;&#160;&#160;

 <B>Date: </B>April 2004<BR>


<P>Split off from <A HREF="
     cwg_defects.html#86">issue 86</A>.</P>

<P>Should binding a reference to the result of a "," operation
whose second operand is a temporary extend the lifetime of the
temporary?</P>
<PRE>
  const SFileName &amp;C = ( f(), SFileName("abc") );
</PRE>

<P><B>Notes from the March 2004 meeting:</B></P>

<P>We think the temporary should be extended.</P>

<P><B>Proposed resolution (October, 2004):</B></P>

<P>Change 12.2
 [class.temporary] paragraph 2 as
indicated:</P>

<BLOCKQUOTE>

... In all these cases, the temporaries created during the
evaluation of the expression initializing the reference, except
the temporary <B>that is the overall result of the expression
[<I>Footnote:</I> For example, if the expression is a comma
expression (5.18
 [expr.comma]) and the value of its
second operand is a temporary, the reference is bound to that
temporary.] and</B> to which the reference is bound, are destroyed at
the end of the full-expression in which they are created and in
the reverse order of the completion of their construction...

</BLOCKQUOTE>

<P><I>[Note: this wording partially resolves <A HREF="
     cwg_defects.html#86">issue 86</A>.  See also <A HREF="
     cwg_defects.html#446">issue 446</A>.]</I></P>

<P><B>Notes from the April, 2005 meeting:</B></P>

<P>The CWG suggested a different approach from the 10/2004 resolution,
leaving 12.2
 [class.temporary] unchanged and adding normative
wording to 5.18
 [expr.comma] specifying that, if the result
of the second operand is a temporary, that temporary is the result of
the comma expression as well.</P>

<P><B>Proposed Resolution (November, 2006):</B></P>

<P>Add the indicated wording to 5.18
 [expr.comma] paragraph 1:</P>

<BLOCKQUOTE>

... The type and value of the result are the type and value of the right
operand; the result is an lvalue if its right operand is an lvalue,
and is a bit-field if its right operand is an lvalue and a bit-field.
<B>If the value of the right operand is a temporary
(12.2
 [class.temporary]), the result is that temporary.</B>

</BLOCKQUOTE>

<BR><BR><HR><A NAME="257"></A><H4>257.
  
Abstract base constructors and virtual base initialization
</H4><B>Section: </B>12.6.2&#160;
 [class.base.init]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>1 Nov 2000<BR>




<P>Must a constructor for an abstract base class provide a
<I>mem-initializer</I> for each virtual base class from which it is
directly or indirectly derived?  Since the initialization of
virtual base classes is performed by the most-derived class, and
since an abstract base class can never be the most-derived class,
there would seem to be no reason to require constructors for
abstract base classes to initialize virtual base classes.</P>

<P>It is not clear from the Standard whether there actually is
such a requirement or not.  The relevant text is found in
12.6.2
 [class.base.init] paragraph 6:</P>

<BLOCKQUOTE>

All sub-objects representing virtual base classes are initialized by
the constructor of the most derived class (1.8
 [intro.object]). If the constructor of the most derived class does not
specify a <I>mem-initializer</I> for a virtual base class <TT>V</TT>,
then <TT>V</TT>'s default constructor is called to initialize the virtual
base class subobject. If <TT>V</TT> does not have an accessible default
constructor, the initialization is ill-formed. A <I>mem-initializer</I>
naming a virtual base class shall be ignored during execution of the
constructor of any class that is not the most derived class.

</BLOCKQUOTE>

<P>This paragraph requires only that the most-derived class's
constructor have a <I>mem-initializer</I> for virtual base classes.
Should the silence be construed as permission for constructors
of classes that are not the most-derived to omit such
<I>mem-initializer</I>s?</P>

<P><U>Christopher Lester</U>, on comp.std.c++, March 19, 2004:
If any of you reading this posting happen to be members of the above
working group, I would like to encourage you to review the suggestion
contained therein, as it seems to me that the final tenor of the
submission is both (a) correct (the silence of the standard DOES
mandate the omission) and (b) describes what most users would
intuitively expect and desire from the C++ language as well.</P>

<P>The suggestion is to make it clearer that constructors for abstract
base classes should not be required to provide initialisers for any
virtual base classes they contain (as only the most-derived class has
the job of initialising virtual base classes, and an abstract base
class cannot possibly be a most-derived class).</P>

<P>For example:</P>
<PRE>
struct A {
  A(const int i, const int j) {};
};

struct B1 : virtual public A {
  virtual void moo()=0;
  B1() {};   // (1) Look! not "B1() : A(5,6) {};"
};

struct B2 : virtual public A {
  virtual void cow()=0;
  B2() {};   // (2) Look! not "B2() : A(7,8) {};"
};

struct C : public B1, public B2 {
  C() : A(2,3) {};
  void moo() {};
  void cow() {};
};

int main() {
  C c;
  return 0;
};
</PRE>

<P>I believe that, by not expressly forbidding it, the standard does
(and should!) allow the above code.  However, as the standard doesn't
expressly allow it either (have I missed something?) there appears to
be room for misunderstanding. For example, g++ version 3.2.3 (and
maybe other versions as well) rejects the above code with messages 
like:</P>
<PRE>
	In constructor `B1::B1()':
	no matching function for call to `A::A()'
	candidates are: A::A(const A&amp;)
         	        A::A(int, int)
</PRE>

<P>Fair enough, the standard is perhaps not clear enough.  But it seems
to be a shame that although this issue was first raised in 2000, we
are still living with it today.</P>

<P>Note that we can work-around, and persuade g++ to compile the above
by either (a) providing a default constructor A() for A, or (b)  
supplying default values for i and j in A(i,j), or (c) replace the
construtors B1() and B2() with the forms shown in the two comments in
the above example.</P>

<P>All three of these workarounds may at times be appropriate, but 
equally there are other times when all of these workarounds are 
particularly bad.  (a) and (b) may be very bad if you are trying to 
enforce string contracts among objects, while (c) is just barmy (I 
mean why did I have to invent random numbers like 5, 6, 7 and 8 just 
to get the code to compile?).</P>

<P>So to to round up, then, my plea to the working group is:

	"at the very least, please make the standard clearer on 
this issue, but preferrably make the decision to expressly allow 
code that looks something like the above"</P>

<P><B>Proposed resolution (March, 2008):</B></P>

<OL>
<LI><P>Add the indicated text (moved from paragraph 6) to the end
of 12.6.2
 [class.base.init] paragraph 3:</P></LI>

<BLOCKQUOTE>

...The initialization of each base and member constitutes a
full-expression. Any expression in a <I>mem-initializer</I> is
evaluated as part of the full-expression that performs the
initialization. <B>A <I>mem-initializer</I> where the
<I>mem-initializer-id</I> names a virtual base class is ignored
during execution of a constructor of any class that is not the
most derived class.</B>

</BLOCKQUOTE>

<LI><P>Change 12.6.2
 [class.base.init] paragraph 4 as follows:</P></LI>

<BLOCKQUOTE>

<P>If a given non-static data member or base class is not named
by a <I>mem-initializer-id</I> (including the case where there is no
<I>mem-initializer-list</I> because the constructor has no
<I>ctor-initializer</I>) <B>and the entity is not a virtual base
class of an abstract class</B>, then</P>

<UL>
<LI><P>If the entity is a non-static non-variant data member of
(possibly cv-qualified) class type (or array thereof) or a base
class, and the entity class is a non-trivial class, the entity is
default-initialized (8.5
 [dcl.init]). If the entity is
a non-static data member of a const-qualified type, the entity
class shall have a user-provided default constructor.</P></LI>

<LI><P>Otherwise, the entity is not initialized. If the entity is
of const-qualified type or reference type, or of a (possibly
cv-qualified) trivial class type (or array thereof) containing
(directly or indirectly) a member of a const-qualified type, the
program is ill-formed.</P></LI> </UL>

<P><B>[<I>Note:</I> An abstract base class (10.4
 [class.abstract]) is never a most derived class, thus its
constructors never initialize virtual base classes, therefore the
corresponding <I>mem-initializer</I>s may be
omitted. &#8212;<I>end note</I>]</B> After the call to a
constructor for class <TT>X</TT> has completed, if a member of
<TT>X</TT> is neither specified in the constructor's
<I>mem-initializer</I>s, nor default-initialized, nor
value-initialized, nor given a value during execution of the
<I>compound-statement</I> of the body of the constructor, the
member has indeterminate value.</P>

</BLOCKQUOTE>

<LI><P>Change 12.6.2
 [class.base.init] paragraph 5 as follows:</P></LI>

<BLOCKQUOTE>

<P>Initialization <S>shall</S> proceed<B>s</B> in the following
order:</P>

<UL>
<LI><P>First, and only for the constructor of the most derived
class <S>as described below</S> <B>(1.8
 [intro.object])</B>, virtual base classes <S>shall be</S> <B>are</B>
initialized in the order they appear on a depth-first
left-to-right traversal of the directed acyclic graph of base
classes, where &#8220;left-to-right&#8221; is the order of
appearance of the base class names in the derived class
<I>base-specifier-list</I>.</P></LI>

<LI><P>Then, direct base classes <S>shall be</S> <B>are</B>
initialized in declaration order as they appear in the
<I>base-specifier-list</I> (regardless of the order of the
<I>mem-initializer</I>s).</P></LI>

<LI><P>Then, non-static data members <S>shall be</S> <B>are</B>
initialized in the order they were declared in the class
definition (again regardless of the order of the
<I>mem-initializer</I>s).</P></LI>

<LI><P>Finally, the <I>compound-statement</I> of the constructor
body is executed.</P></LI>
</UL>

<P>[<I>Note:</I> the declaration order is mandated to ensure that
base and member subobjects are destroyed in the reverse order of
initialization. &#8212;<I>end note</I>]</P>

</BLOCKQUOTE>

<P><I>[Drafting note: The &#8220;shall&#8221; clauses above were
rewritten to accord with the usual phrasing throughout the rest of
the Standard.]</I></P>

<LI><P>Remove all the normative text in 12.6.2
 [class.base.init]
paragraph 6, keeping the example:</P></LI>

<BLOCKQUOTE>

<S>All subobjects representing virtual base classes are initialized
by the constructor of the most derived class (1.8
 [intro.object]). If the constructor of the most derived class does
not specify a <I>mem-initializer</I> for a virtual base class
<TT>V</TT>, then <TT>V</TT>'s default constructor is called to
initialize the virtual base class subobject. If <TT>V</TT> does
not have an accessible default constructor, the initialization is
ill-formed. A <I>mem-initializer</I> naming a virtual base class shall
be ignored during execution of the constructor of any class that
is not the most derived class.</S> [<I>Example:</I>...

</BLOCKQUOTE>

</OL>

<BR><BR><HR><A NAME="111"></A><H4>111.
  
Copy constructors and cv-qualifiers
</H4><B>Section: </B>12.8&#160;
 [class.copy]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jack Rouse
 &#160;&#160;&#160;

 <B>Date: </B>4 May 1999<BR>





<P><U>Jack Rouse:</U>
In 12.8
 [class.copy]
 paragraph 8,
the standard includes
the following about the copying of class subobjects in such a
constructor:</P>
<UL>
<LI>if the subobject is of class type, the copy constructor for
the class is used;</LI>
</UL>

But there can be multiple copy constructors declared by the user with
differing cv-qualifiers on the source parameter.  I would assume
overload resolution would be used in such cases.  If so then the
passage above seems insufficient.

<P><B>Mike Miller:</B>
I'm more concerned about
12.8
 [class.copy]
 paragraph 7,
which lists the situations in
which an implicitly-defined copy constructor can render a
program ill-formed.  Inaccessible and ambiguous copy
constructors are listed, but not a copy constructor with a
cv-qualification mismatch.  These two paragraphs taken together
could be read as requiring the calling of a copy constructor
with a non-const reference parameter for a const data member.</P>

<P><B>Proposed Resolution (November, 2006):</B></P>

<P>This issue is resolved by the proposed resolution for
<A HREF="
     cwg_active.html#535">issue 535</A>.</P>
<BR><BR><HR><A NAME="535"></A><H4>535.
  
Copy construction without a copy constructor
</H4><B>Section: </B>12.8&#160;
 [class.copy]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>7 October 2005<BR>


<P>Footnote 112 (12.8
 [class.copy] paragraph 2) says,</P>

<BLOCKQUOTE>

Because a template constructor is never a copy constructor, the
presence of such a template does not suppress the implicit declaration
of a copy constructor. Template constructors participate in overload
resolution with other constructors, including copy constructors, and a
template constructor may be used to copy an object if it provides a
better match than other constructors.

</BLOCKQUOTE>

<P>However, many of the stipulations about copy construction are
phrased to refer only to &#8220;copy constructors.&#8221;  For
example, 12.8
 [class.copy] paragraph 14 says,</P>

<BLOCKQUOTE>

A program is ill-formed if the copy constructor...
for an object is implicitly used and the special member
function is not accessible (clause 11
 [class.access]).

</BLOCKQUOTE>

<P>Does that mean that using an inaccessible template constructor
to copy an object is permissible, because it is not a &#8220;copy
constructor?&#8221;  Obviously not, but each use of the term
&#8220;copy constructor&#8221; in the Standard should be examined
to determine if it applies strictly to copy constructors or to
any constructor used for copying.  (A similar issue applies to
&#8220;copy assignment operators,&#8221; which have the same
relationship to assignment operator function templates.)</P>

<P><B>Proposed Resolution (February, 2008):</B></P>

<OL><LI><P>Change 3.2
 [basic.def.odr] paragraph 2 as follows:</P></LI>

<BLOCKQUOTE>

... [<I>Note:</I> this covers calls to named functions (5.2.2
 [expr.call]), operator overloading (clause 13
 [over]),
user-defined conversions (12.3.2
 [class.conv.fct]), allocation
function for placement new (5.3.4
 [expr.new]), as well as
non-default initialization (8.5
 [dcl.init]). A <S>copy</S>
constructor <B>selected to copy class objects</B> is used even if the
call is actually elided by the implementation (12.8
 [class.copy]). &#8212;<I>end note</I>] ... <S>A copy-assignment function
for a class</S> <B>An assignment operator function in a class</B>
is used by an implicitly-defined copy-assignment function
for another class as specified in 12.8
 [class.copy]...

</BLOCKQUOTE>

<LI><P>Delete 12.1
 [class.ctor] paragraphs 10 and 11:</P></LI>

<BLOCKQUOTE>

<P><S>A copy constructor (12.8
 [class.copy]) is used to copy
objects of class type.</S></P>

<P><S>A union member shall not be of a class type (or array thereof)
that has a non-trivial constructor.</S></P>

</BLOCKQUOTE>

<LI><P>Replace the &#8220;example&#8221; in 12.2
 [class.temporary]
paragraph 1 with a note as follows:</P></LI>

<BLOCKQUOTE>

<S>[<I>Example:</I> even if the copy constructor is not called, all
the semantic restrictions, such as accessibility (clause 11
 [class.access]), shall be satisfied. &#8212;<I>end example</I>]</S>
<B>[<I>Note:</I> This includes accessibility (clause 11
 [class.access]) for the constructor selected. &#8212;<I>end note</I>]</B>

</BLOCKQUOTE>

<LI><P>Change 12.8
 [class.copy] paragraph 7 as follows:</P></LI>

<BLOCKQUOTE>

<P>A non-user-provided copy constructor is <I>implicitly defined</I>
if it is used <S>to initialize an object of its class type from a copy
of an object of its class type or of a class type derived from its
class type</S> <B>(3.2
 [basic.def.odr])</B>. [<I>Footnote:</I>
See 8.5
 [dcl.init] for more details on direct and copy
initialization. &#8212;<I>end footnote</I>] [<I>Note:</I> the copy
constructor is implicitly defined even if the implementation elided
<S>its use (12.2
 [class.temporary])</S> <B>the copy operation
(12.8
 [class.copy])</B>. &#8212;<I>end note</I>] <S>A program
is ill-formed if the class for which a copy constructor is implicitly
defined or explicitly defaulted has:</S></P>

<S><UL>
<LI><P>a non-static data member of class type (or array thereof) with an inaccessible or ambiguous copy constructor, or</P></LI>

<LI><P>a base class with an inaccessible or ambiguous copy constructor.</P></LI>

</UL></S><P>Before the non-user-provided copy constructor for a class is
implicitly defined...</P>

</BLOCKQUOTE>

<LI><P>Change 12.8
 [class.copy] paragraph 8 as follows:</P></LI>

<BLOCKQUOTE>

<P>...Each subobject is copied in the manner appropriate to its type:</P>

<UL>
<LI><P>if the subobject is of class type, <S>the copy constructor for
the class is used</S> <B>direct-initialization (8.5
 [dcl.init]) is performed [<I>Note:</I> If overload resolution fails
or the constructor selected by overload resolution is inaccessible
(11
 [class.access]) in the context of <TT>X</TT>, the program is
ill-formed. &#8212;<I>end note</I>]</B>;</P></LI>

<LI><P>if the subobject is an array...</P></LI></UL>

</BLOCKQUOTE>

<P><I>[Drafting note: 8.5
 [dcl.init] paragraph 15 requires
&#8220;unambiguous&#8221; and 13.3
 [over.match] paragraph 3
requires &#8220;accessible,&#8221; thus no need for normative text
here.]</I></P>

<LI><P>Change 12.8
 [class.copy] paragraph 12 as follows:</P></LI>

<BLOCKQUOTE>

<P>A non-user-provided copy assignment operator is <I>implicitly
defined</I> when <S>an object of its class type is assigned a value of
its class type or a value of a class type derived from its class
type</S> <B>it is used (3.2
 [basic.def.odr])</B>. A program is
ill-formed if the class for which a copy assignment operator is
implicitly defined or explicitly defaulted has<S>:</S> <B>a
non-static data member of const or reference type.</B></P>

<S><UL>
<LI><P>a non-static data member of const type, or</P></LI>

<LI><P>a non-static data member of reference type, or</P></LI>

<LI><P>a non-static data member of class type (or array thereof) with
an inaccessible copy assignment operator, or</P></LI>

<LI><P>a base class with an inaccessible copy assignment
operator.</P></LI>
</UL></S>

</BLOCKQUOTE>

<LI><P>Change 12.8
 [class.copy] paragraph 13 as follows:</P></LI>

<BLOCKQUOTE>

<P>... Each subobject is assigned in the manner appropriate to its type:</P>

<UL>
<LI><P>if the subobject is of class type, <S>the copy assignment
operator for the class</S> <B>the assignment operator function
selected by overload resolution (13.3
 [over.match]) for that
class</B> is used (as if by explicit qualification; that
is, ignoring any possible virtual overriding functions in more derived
classes) <B>[<I>Note:</I> If overload resolution fails or the assignment
operator function selected by overload resolution is inaccessible
(11
 [class.access]) in the context of <TT>X</TT>, the program
is ill-formed. &#8212;<I>end note</I>]</B>;</P></LI>

<LI><P>if the subobject is an array...</P></LI>
</UL>

</BLOCKQUOTE>

<LI><P>Delete 12.8
 [class.copy] paragraph 14:</P></LI>

<BLOCKQUOTE>

<S>A program is ill-formed if the copy constructor or the copy
assignment operator for an object is implicitly used and the special
member function is not accessible (clause 11
 [class.access]). [<I>Note:</I> Copying one object into another using the
copy constructor or the copy assignment operator does not change the
layout or size of either object. &#8212;<I>end note</I>]</S>

</BLOCKQUOTE>

<LI><P>Change 12.8
 [class.copy] paragraph 15 as follows:</P></LI>

<BLOCKQUOTE>

When certain criteria are met, an implementation is allowed to omit
the copy construction of a class object, even if the <S>copy</S> constructor
<B>selected for the copy operation</B> and/or <B>the</B> destructor
for the object have side effects. In such cases, the implementation
treats the source and target of the omitted copy operation as simply
two different ways of referring to the same object, and the
destruction of that object occurs at the later of the times when the
two objects would have been destroyed without the optimization.
[<I>Footnote:</I> Because only one object is destroyed instead of two,
and one <S>copy</S> constructor is not executed, there is still one
object destroyed for each one constructed. &#8212;<I>end footnote</I>]
This elision...

</BLOCKQUOTE>

<LI><P>Change 13.3.3.1.2
 [over.ics.user] paragraph 4 as follows:</P></LI>

<BLOCKQUOTE>

A conversion of an expression of class type to the same class type is
given Exact Match rank, and a conversion of an expression of class
type to a base class of that type is given Conversion rank, in spite
of the fact that a <S>copy</S> constructor (i.e., a user-defined
conversion function) is called for those cases.

</BLOCKQUOTE>

<LI><P>Change 15.1
 [except.throw] paragraph 3 as follows:</P></LI>

<BLOCKQUOTE>

A <I>throw-expression</I> initializes a temporary object, called the
<I>exception object</I>, <S>the type of which</S> <B>by
copy-initialization (8.5
 [dcl.init]).  The type of that
temporary object</B> is determined...

</BLOCKQUOTE>

<LI><P>Change 15.1
 [except.throw] paragraph 5 as follows:</P></LI>

<BLOCKQUOTE>

When the thrown object is a class object, the <S>copy</S> constructor
<B>selected for the copy-initialization</B> and the destructor shall
be accessible, even if the copy operation is elided (12.8
 [class.copy]).

</BLOCKQUOTE>

<LI><P>Change 15.3
 [except.handle] paragraphs 16-17 as follows:</P></LI>

<BLOCKQUOTE>

<P>When the <I>exception-declaration</I> specifies a class type, <S>a
copy constructor</S> <B>copy-initialization (8.5
 [dcl.init])</B> is used to initialize either the object declared in
the <I>exception-declaration</I> or, if
the <I>exception-declaration</I> does not specify a name, a temporary
object of that type.  The object shall not have an abstract class
type. The object is destroyed when the handler exits, after the
destruction of any automatic objects initialized within the
handler. The <S>copy</S> constructor <B>selected for the
copy-initialization</B> and <B>the</B> destructor shall be accessible
in the context of the handler<B>, even if the copy operation is elided
(12.8
 [class.copy])</B>. <S>If the copy constructor and
destructor are implicitly declared (12.8
 [class.copy]), such a
use in the handler causes these functions to be implicitly defined;
otherwise, the program shall provide a definition for these
functions.</S></P>

<P><S>The copy constructor and destructor associated with the object
shall be accessible even if the copy operation is elided (12.8
 [class.copy]).</S></P>

</BLOCKQUOTE>

<LI><P>Change the footnote in 15.5.1
 [except.terminate] paragraph 1
as follows:</P></LI>

<BLOCKQUOTE>

[<I>Footnote:</I> For example, if the object being thrown is of a
class <S>with a copy constructor</S> <B>type</B>,
<TT>std::terminate()</TT> will be called if <S>that copy constructor</S>
<B>the constructor selected to copy the object</B> exits with an
exception during a <TT>throw</TT>. &#8212;<I>end footnote</I>]

</BLOCKQUOTE>

</OL>

<P>(This resolution also resolves <A HREF="
     cwg_active.html#111">issue 111</A>.)</P>

<P><I>[Drafting note: The following do not require changes:
5.17
 [expr.ass] paragraph 4;
9
 [class] paragraph 5;
9.5
 [class.union] paragraph 1;
12.2
 [class.temporary] paragraph 2;
12.8
 [class.copy] paragraphs 1-2;
15.4
 [except.spec] paragraph 14.]</I></P>

<P><B>Notes from February, 2008 meeting:</B></P>

<P>These changes overlap those that will be made when concepts are
added.  This issue will be maintained in &#8220;review&#8221; status
until the concepts proposal is adopted and any conflicts will be
resolved at that point.</P>

<BR><BR><HR><A NAME="574"></A><H4>574.
  
Definition of &#8220;copy assignment operator&#8221;
</H4><B>Section: </B>12.8&#160;
 [class.copy]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Adamczyk
 &#160;&#160;&#160;

 <B>Date: </B>15 April 2006<BR>


<P>Is the following a &#8220;copy assignment operator?&#8221;</P>

<PRE>
    struct A {
        const A&amp; operator=(const A&amp;) volatile;
    };
</PRE>

<P>12.8
 [class.copy] paragraph 9 doesn't say one way or the
other whether cv-qualifiers on the function are allowed.  (A similar
question applies to the <TT>const</TT> case, but I avoided that example
because it seems so wrong one tends to jump to a conclusion before
seeing what the standard says.)</P>

<P>Since the point of the definition of &#8220;copy assignment
operator&#8221; is to control whether the compiler generates a default
version if the user doesn&#8217;t, I suspect the correct answer is
that neither <TT>const</TT> nor <TT>volatile</TT> cv-qualification
on <TT>operator=</TT> should be allowed for a &#8220;copy assignment
operator.&#8221; A user can write an <TT>operator=</TT> like that, but
it doesn't affect whether the compiler generates the default one.</P>

<P><B>Proposed Resolution (November, 2006):</B></P>

<P>Change 12.8
 [class.copy] paragraph 9 as follows:</P>

<BLOCKQUOTE>

A user-declared <I>copy</I> assignment operator <TT>X::operator=</TT>
is a non-static non-template <B>non-volatile non-const</B> member
function of class <TT>X</TT> with exactly one parameter of
type <TT>X</TT>, <TT>X&amp;</TT>, <TT>const X&amp;</TT>, <TT>volatile
X&amp;</TT> or <TT>const volatile X&amp;</TT>.

</BLOCKQUOTE>

<P><I>[Drafting note: If a user-declared volatile <TT>operator=</TT>
prevented the implicit declaration of the copy assignment operator,
all assignments for objects of the given class (even to non-volatile
objects) would pay the penalty for volatile write accesses in the
user-declared <TT>operator=</TT>, despite not needing it.]</I></P>

<P><B>Additional note (December, 2008):</B></P>



<P>The proposed resolution addresses only cv-qualified assignment
operators and is silent on ref-qualified versions.  However, it would
seem that the spirit of the resolution would indicate that a ref-qualified
assignment operator would not be considered a copy assignment operator.</P>

<P>There appears to be an emerging idiom that relies on the idea that
providing an lvalue-only assignment operator would prevent assignment
to rvalues:</P>

<PRE>
    struct A {
      A&amp; operator=(const A&amp;) &amp;; // disable assignemt to rvalue
    };
</PRE>

<P>The resolution should also be reconsidered in light of the use of
a const-qualified assignment operator as part of the implementation
of a proxy class, where the proxy object itself is constant and should
not be changed, but the copy assignment operator would apply to the
object to which the proxy object refers.</P>

<BR><BR><HR><A NAME="653"></A><H4>653.
  
Copy assignment of unions
</H4><B>Section: </B>12.8&#160;
 [class.copy]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jens Maurer
 &#160;&#160;&#160;

 <B>Date: </B>3 October 2007<BR>




<P>How does copy assignment for unions work?  For example,</P>

<PRE>
  union U {
    int a;
    float b;
  };

  void f() {
    union U u = { 5 };
    union U v;
    v = u;    // what happens here?
  }
</PRE>

<P>9.5
 [class.union] is silent on the issue, therefore it
seems that 12.8
 [class.copy] applies.  There is no special
case for unions, thus paragraph 13 (memberwise assignment of
subobjects) seems to apply.  That would seem to imply these actions in
the compiler-generated copy assignment operator:</P>

<PRE>
  v.a = u.a;
  v.b = u.b;
</PRE>

<P>And this is just wrong.  For example, the lifetime of
<TT>v.a</TT> ends once the second assignment reuses the memory
of <TT>v.a</TT>.</P>

<P>We should probably prescribe &#8220;memcpy&#8221; copying for
unions (both for the copy constructor and the assignment operator)
unless the user provided his own special member function.</P>

<P><B>Proposed resolution (March, 2008):</B></P>

<OL><LI><P>Change 12.8
 [class.copy] paragraph 8 as follows:</P></LI>

<BLOCKQUOTE>

The implicitly-defined or explicitly-defaulted copy constructor for
<B>a non-union</B> class <TT>X</TT> performs a memberwise copy of its
subobjects...

</BLOCKQUOTE>

<LI><P>Add a new paragraph after 12.8
 [class.copy]
paragraph 8:</P></LI>

<BLOCKQUOTE>

The implicitly-defined or explicitly-defaulted copy constructor for a
union <TT>X</TT> where all members have a trivial copy constructor
copies the object representation (3.9
 [basic.types]) of
<TT>X</TT>. [<I>Note:</I> The behavior is undefined if <TT>X</TT> is
not a trivial type. &#8212;<I>end note</I>]

</BLOCKQUOTE>

<LI><P>Change 12.8
 [class.copy] paragraph 13 as follows:</P></LI>

<BLOCKQUOTE>

The implicitly-defined or explicitly-defaulted copy assignment
operator for <B>a non-union</B> class <TT>X</TT> performs memberwise
assignment of its subobjects...

</BLOCKQUOTE>

<LI><P>Add a new paragraph after 12.8
 [class.copy]
paragraph 13:</P></LI>

<BLOCKQUOTE>

The implicitly-defined or explicitly-defaulted copy assignment
operator for a union <TT>X</TT> where all members have a trivial copy
assignment operator copies the object representation (3.9
 [basic.types]) of <TT>X</TT>. [<I>Note:</I> The behavior is undefined if
<TT>X</TT> is not a trivial type. &#8212;<I>end note</I>]

</BLOCKQUOTE>

</OL>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>The proposed wording needs to be updated to reflect the
changes adopted in papers N2757 and N2762, resolving <A HREF="
     cwg_defects.html#683">issue 683</A>, which require &#8220;no
non-trivial&#8221; special member functions instead of &#8220;a
trivial&#8221; function.  Also, the notes regarding undefined
behavior are incorrect, because the member functions involved are
defined as deleted when there are non-trivial members.</P>

<P><B>Proposed resolution (October, 2008):</B></P>

<OL>
<LI><P>Change 12.8
 [class.copy] paragraph 8 as follows:</P></LI>

<BLOCKQUOTE>

The implicitly-defined or explicitly-defaulted copy constructor for
<B>a non-union</B> class <TT>X</TT> performs a memberwise copy of its
subobjects...

</BLOCKQUOTE>

<LI><P>Add a new paragraph following 12.8
 [class.copy]
paragraph 8:</P></LI>

<BLOCKQUOTE>

The implicitly-defined or explicitly-defaulted copy constructor for a
union <TT>X</TT> copies the object representation (3.9
 [basic.types]) of <TT>X</TT>.

</BLOCKQUOTE>

<LI><P>Change 12.8
 [class.copy] paragraph 13 as follows:</P></LI>

<BLOCKUOTE>

The implicitly-defined or explicitly-defaulted copy assignment
operator for <B>a non-union</B> class <TT>X</TT> performs memberwise
assignment of its subobjects...

</BLOCKUOTE>

<LI><P>Add a new paragraph following 12.8
 [class.copy]
paragraph 13:</P></LI>

<BLOCKQUOTE>

The implicit-defined or explicitly-defaulted copy assignment operator
for a union <TT>X</TT> copies the object representation
(3.9
 [basic.types]) of <TT>X</TT>.

</BLOCKQUOTE>

</OL>

<BR><BR><HR><A NAME="667"></A><H4>667.
  
Trivial special member functions that cannot be implicitly defined
</H4><B>Section: </B>12.8&#160;
 [class.copy]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Widman
 &#160;&#160;&#160;

 <B>Date: </B>14 December 2007<BR>




<P>Should the following class have a trivial copy assignment operator?</P>

<PRE>
    struct A {
        int&amp; m;
        A();
        A(const A&amp;);
    };
</PRE>

<P>12.8
 [class.copy] paragraph 11 does not mention whether the
presence of reference members (or cv-qualifiers, etc.) should affect
triviality.  Should it?</P>

<P>One reason why this matters is that implementations have to make
the builtin type trait operator <TT>__has_trivial_default_ctor(T)</TT>
work so that they can support the type trait template
<TT>std::has_trivial_default_constructor</TT>.</P>

<P>Assuming the answer is &#8220;yes,&#8221; it looks like we probably
need similar wording for trivial default and trivial copy ctors.
</P>

<P><B>Notes from the February, 2008 meeting:</B></P>

<P>Deleted special member functions are also not trivial.  Resolution
of this issue should be coordinated with the concepts proposal.</P>

<P><B>Notes from the June, 2008 meeting:</B></P>

<P>It appears that this issue will be resolved by the concepts
proposal directly.  The issue is in &#8220;review&#8221; status to
check if that is indeed the case in the final version of the
proposal.</P>

<BR><BR><HR><A NAME="704"></A><H4>704.
  
To which <I>postfix-expression</I>s does overload resolution apply?
</H4><B>Section: </B>13.3.1.1&#160;
 [over.match.call]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jens Maurer
 &#160;&#160;&#160;

 <B>Date: </B>29 July, 2008<BR>




<P>There are several problems with the phrasing of 13.3.1.1
 [over.match.call] paragraphs 1 and 3.  Paragraph 1 reads,</P>

<BLOCKQUOTE>

Recall from 5.2.2
 [expr.call], that a <I>function
call</I> is a <I>postfix-expression</I>, possibly nested
arbitrarily deep in parentheses, followed by an optional
<I>expression-list</I> enclosed in parentheses:

<UL><TT>(</TT> ... <TT>(</TT><SUB><I>opt</I></SUB> <I>postfix-expression</I> <TT>)</TT> ... <TT>)</TT><SUB><I>opt</I></SUB> <TT>(</TT> <I>expression-list<SUB>opt</SUB></I> <TT>)</TT></UL>

Overload resolution is required if the <I>postfix-expression</I>
is the name of a function, a function template (14.5.6
 [temp.fct]), an object of class type, or a set of
pointers-to-function.

</BLOCKQUOTE>

<P>Aside from the fact that directly addressing the reader
(&#8220;Recall that...&#8221;) is stylistically incongruous with
the rest of the Standard, as well as the fact that 5.2.2
 [expr.call] doesn't mention parentheses at all, this wording
does not cover member function calls: a member access expression
isn't &#8220;the name&#8221; of anything.  This should perhaps be
reworded to refer to being either an <I>id-expression</I> or the
<I>id-expression</I> in a member access expression.  This could
be either by using two lines in the &#8220;of the form&#8221;
citation or in the discussion following the syntax reference. 
</P>

<P>In addition, paragraph 3 refers to &#8220;a
<I>postfix-expression</I> of the form <TT>&amp;F</TT>,&#8221;
which is an oxymoron: <TT>&amp;F</TT> is a
<I>unary-expression</I>, not a <I>postfix-expression</I>.  One
possibility would be to explicitly include the parentheses needed
in this case, i.e., &#8220;a <I>postfix-expression</I> of the
form <TT>(&amp;F)</TT>...&#8221;</P>

<P><B>Proposed resolution (September, 2008):</B></P>

<P>Replace the entirety of 13.3.1.1
 [over.match.call] with
the following two paragraphs:</P>

<BLOCKQUOTE>

<P>In a function call (5.2.2
 [expr.call])</P>

<UL><I>postfix-expression</I> <TT>(</TT> <I>expression-list<SUB>opt</SUB></I> <TT>)</TT></UL>

<P>let <I>e</I> be the expression resulting from the removal of all
surrounding parentheses from <I>postfix-expression</I>.  [<I>Note:</I>
This includes parentheses that might be syntactically required for
<I>e</I> to be used as a <I>postfix-expression</I>. &#8212;<I>end
note</I>] If <I>e</I> is an <I>id-expression</I> that names a function
or function template (14.5.6
 [temp.fct]) or a class member
access (5.2.5
 [expr.ref]) whose <I>id-expression</I> names
a function or function template, overload resolution is applied as
specified in 13.3.1.1.1
 [over.call.func].  If <I>e</I> evaluates
to an object of class type, overload resolution is applied as specified
in 13.3.1.1.2
 [over.call.object].</P>

<P>If <I>e</I> is of the form <TT>&amp;F</TT>, where <TT>F</TT> names
a set of overloaded functions, the function call expression is
treated as
<TT>F(</TT>&#160;<I>expression-list<SUB>opt</SUB></I>&#160;<TT>)</TT>,
and overload resolution is applied as specified in
13.3.1.1.1
 [over.call.func].  If the function selected by
overload resolution is a non-static member function, the program is
ill-formed. [<I>Note:</I> The resolution of <TT>&amp;F</TT> in
other contexts is described in 13.4
 [over.over].
&#8212;<I>end note</I>]</P>

</BLOCKQUOTE>

<BR><BR><HR><A NAME="495"></A><H4>495.
  
Overload resolution with template and non-template conversion functions
</H4><B>Section: </B>13.3.3&#160;
 [over.match.best]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Nathan Sidwell
 &#160;&#160;&#160;

 <B>Date: </B>20 Dec 2004<BR>


<P>
The overload resolution rules for ranking a template against a
non-template function differ for conversion functions in a
surprising way.  13.3.3
 [over.match.best] lists four checks,
the last three concern this report.  For the non-conversion
operator case, checks 2 and 3 are applicable, whereas for the
conversion operator case checks 3 and 4 are applicable. Checks 2
and 4 concern the ranking of argument and return value conversion
sequences respectively.  Check 3 concerns only the templatedness
of the functions being ranked, and will prefer a non-template to
a template.  Notice that this check happens after argument
conversion sequence ranking, but <I>before</I> return value
conversion sequence ranking.  This has the effect of always
selecting a non-template conversion operator, as the following
example shows:
</P>

<PRE>
    struct C
    {
      inline operator int () { return 1; }
      template &lt;class T&gt; inline operator T () { return 0; }
    };

    inline long f (long x) { return x; }

    int
    main (int argc, char *argv[])
    {
      return f (C ());
    }
</PRE>

<P>
The non-templated <TT>C::operator int</TT> function will be
selected, rather than the apparently better
<TT>C::operator long&lt;long&gt;</TT> instantiation.  This is a
surprise, and resulted in a bug report where the user expected
the template to be selected.  In addition some C++ compilers have
implemented the overload ranking as if checks 3 and 4 were
transposed.
</P>

<P>
Is this ordering accidental, or is there a rationale?
</P>

<P><B>Notes from the April, 2005 meeting:</B></P>

<P>The CWG agreed that the template/non-template distinction should
be the final tie-breaker.</P>

<P><B>Proposed resolution (March, 2007):</B></P>

<P>In the second bulleted list of 13.3.3
 [over.match.best]
paragraph 1, move the second and third bullets to the end of the list,
to read as follows:</P>

<BLOCKQUOTE>

<UL>

<LI><P>for some argument <I>j</I>, ICS<I>j</I>(<TT>F1</TT>) is a
better conversion sequence than ICS<I>j</I>(<TT>F2</TT>), or, if not
that,</P></LI>

<LI><P>the context is an initialization by user-defined conversion
(see 8.5
 [dcl.init], 13.3.1.5
 [over.match.conv], and
13.3.1.6
 [over.match.ref]) and the standard conversion sequence
from the return type of <TT>F1</TT> to the destination type (i.e., the
type of the entity being initialized) is a better conversion sequence
than the standard conversion sequence from the return type
of <TT>F2</TT> to the destination type, [<I>Example:</I> ...
&#8212;<I>end example</I>] or, if not that,</P></LI>

<P><LI><TT>F1</TT> is a non-template function and <TT>F2</TT> is a
function template specialization, or, if not that,</LI></P>

<LI><P><TT>F1</TT> and <TT>F2</TT> are function template
specializations, and the function template for <TT>F1</TT> is more
specialized than the template for <TT>F2</TT> according to the partial
ordering rules described in 14.5.6.2
 [temp.func.order].</P></LI>

</UL>

</BLOCKQUOTE>

<BR><BR><HR><A NAME="657"></A><H4>657.
  
Abstract class parameter in synthesized declaration
</H4><B>Section: </B>14.8.2&#160;
 [temp.deduct]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>31 October 2007<BR>


<P>A customer of ours recently brought the following example to
our attention.  There's some question as to whether the
Standard adequately addresses this example, and if it does,
whether the outcome is what we'd like to see.  Here's the
example:</P>

<PRE>
    struct Abs {
      virtual void x() = 0;
    };

    struct Der: public Abs {
      virtual void x();
    };

    struct Cnvt {
      template &lt;typename F&gt; Cnvt(F);
    };

    void foo(Cnvt a);
    void foo(Abs &amp;a);

    void f() {
      Der d;
      Abs *a = &amp;d;
      foo(*a);        //<SPAN STYLE="font-family:Times"><I> #1</I></SPAN>
      return 0;
    }
</PRE>

<P>The question is how to perform overload resolution for the call at
#1.  To do that, we need to determine whether <TT>foo(Cnvt)</TT> is a
viable function.  That entails deciding whether there is an implicit
conversion sequence that converts <TT>Abs</TT> (the type
of <TT>*a</TT> in the call) to <TT>Cnvt</TT> (13.3.2
 [over.match.viable] paragraph 3), and that involves a recursive invocation
of overload resolution.</P>

<P>The initialization of the parameter of <TT>foo(Cnvt)</TT> is a case
of copy-initialization of a class by user-defined conversion, so the
candidate functions are the converting constructors of <TT>Cnvt</TT>
(13.3.1.4
 [over.match.copy] paragraph 1), of which there are two:
the implicitly-declared copy constructor and the constructor
template.</P>

<P>According to 14.7.1
 [temp.inst] paragraph 8,</P>

<BLOCKQUOTE>

If a function template or a member function template specialization is
used in a way that involves overload resolution, a declaration of the
specialization is implicitly instantiated (14.8.3
 [temp.over]).

</BLOCKQUOTE>

<P>Template argument deduction results in &#8220;synthesizing&#8221;
(14.8.3
 [temp.over] paragraph 1) (or &#8220;instantiating,&#8221; 14.7.1
 [temp.inst] paragraph 8) the declaration</P>

<PRE>
    Cnvt::Cnvt(Abs)
</PRE>

<P>Because <TT>Abs</TT> is an abstract class, this declaration
violates the restriction of 10.4
 [class.abstract] paragraph 3
(&#8220;An abstract class shall not be used as a parameter
type...&#8221;), and because a parameter of an abstract class type
does not cause a deduction failure (it's not in the bulleted list in
14.8.2
 [temp.deduct] paragraph 2), the program is ill-formed.
This error is reported by both EDG and Microsoft compilers, but not by
g++.</P>

<P>It seems unfortunate that the program would be rendered
ill-formed by a semantic violation in a declaration synthesized
solely for the purpose of overload resolution analysis;
<TT>foo(Cnvt)</TT> would not be selected by overload resolution, so
<TT>Cnvt::Cnvt(Abs)</TT> would not be instantiated.</P>

<P>There's at least some indication that a parameter with an
abstract class type should be a deduction failure; an array
element of abstract class type is a deduction failure, so one
might expect that a parameter would be, also.</P>

<P>(See also <A HREF="
     cwg_defects.html#339">issue 339</A>; this question
might be addressed as part of the direction described in the notes
from the July, 2007 meeting.)</P>

<P><B>Notes from the June, 2008 meeting:</B></P>

<P>Paper N2634, adopted at the June, 2008 meeting, replaces the
normative list of specific errors accepted as deduction failures
by a general statement covering all &#8220;invalid types and
expressions in the immediate context of the function type and its
template parameter types,&#8221; so the code is now
well-formed. However, the previous list is now a note, and the
note should be updated to mention this case.
</P>

<P><B>Proposed resolution (August, 2008):</B></P>

<P>Add a new bullet following the last bullet of the note in
14.8.2
 [temp.deduct] paragraph 8 as follows:</P>

<UL><LI><P>Attempting to create a function type in which a
parameter type or the return type is an abstract class type
(10.4
 [class.abstract]).</P></LI></UL>

<BR><BR><HR><A NAME="692"></A><H4>692.
  
Partial ordering of variadic class template partial specializations
</H4><B>Section: </B>14.8.2.5&#160;
 [temp.deduct.type]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Doug Gregor
 &#160;&#160;&#160;

 <B>Date: </B>16 April, 2008<BR>




<P>14.8.2.5
 [temp.deduct.type] paragraph 22 describes how we
cope with partial ordering between two function templates that
differ because one has a function parameter pack while the other
has a normal function parameter.  However, this paragraph was
meant to apply to template parameter packs as well, e.g., to help
with partial ordering of class template partial specializations:</P>

<PRE>
   template &lt;class T1, class ...Z&gt; class S; // #1
   template &lt;class T1, class ...Z&gt; class S&lt;T1, const Z&amp;...&gt; {}; // #2
   template &lt;class T1, class T2&gt; class S&lt;T1, const T2&amp;&gt; {};; // #3
   S&lt;int, const int&amp;&gt; s; // both #2 and #3 match; #3 is more specialized
</PRE>

<P><U>Suggested resolution:</U></P>

<P>Change 14.8.2.5
 [temp.deduct.type] paragraphs 9-10 as follows
(and add the example above to paragraph 9):</P>

<BLOCKQUOTE>

<P>If <TT>P</TT> has a form that contains &lt;<TT>T</TT>&gt; or
&lt;<TT>i</TT>&gt;, then each argument
<TT>P</TT><SUB><I>i</I></SUB> of the respective template argument
list <TT>P</TT> is compared with the corresponding argument
<TT>A</TT><SUB><I>i</I></SUB> of the corresponding template
argument list of <TT>A</TT>. If the template argument list of
<TT>P</TT> contains a pack expansion that is not the last
template argument, the entire template argument list is a
non-deduced context. If <TT>P</TT><SUB><I>i</I></SUB> is a pack
expansion, then the pattern of <TT>P</TT><SUB><I>i</I></SUB> is
compared with each remaining argument in the template argument
list of <TT>A</TT>. Each comparison deduces template arguments
for subequent positions in the template parameter packs expanded
by <TT>P</TT><SUB><I>i</I></SUB>. <B>During partial ordering
(14.8.2.4
 [temp.deduct.partial]), if <TT>A</TT><SUB><I>i</I></SUB>
was originally a pack expansion and <TT>P</TT><SUB><I>i</I></SUB>
is not a pack expansion, or if <TT>P</TT> does not contain a
template argument corresponding to <TT>A</TT><SUB><I>i</I></SUB>,
argument deduction fails.</B></P>

<P>Similarly, if <TT>P</TT> has a form that contains
<TT>(T)</TT>, then each parameter type
<TT>P</TT><SUB><I>i</I></SUB> of the respective
<I>parameter-type-list</I> of <TT>P</TT> is compared with the
corresponding parameter type <TT>A</TT><SUB><I>i</I></SUB> of the
corresponding <I>parameter-type-list</I> of <TT>A</TT>. If the
<I>parameter-declaration</I> corresponding to
<TT>P</TT><SUB><I>i</I></SUB> is a function parameter pack, then
the type of its <I>declarator-id</I> is compared with each
remaining parameter type in the <I>parameter-type-list</I> of
<TT>A</TT>. Each comparison deduces template arguments for
subsequent positions in the template parameter packs expanded by
the function parameter pack. <B>During partial ordering
(14.8.2.4
 [temp.deduct.partial]), if <TT>A</TT><SUB><I>i</I></SUB>
was originally a function parameter pack and
<TT>P</TT><SUB><I>i</I></SUB> is not a function parameter
pack, or if <TT>P</TT> does not contain a function parameter type
corresponding to <TT>A</TT><SUB><I>i</I></SUB>, argument deduction
fails.</B> [<I>Note:</I> A function parameter pack
can only occur at the end of a <I>parameter-declaration-list</I>
(8.3.5
 [dcl.fct]). &#8212;<I>end note</I>]</P>

</BLOCKQUOTE>

<BR><BR><HR><A NAME="601"></A><H4>601.
  
Type of literals in preprocessing expressions
</H4><B>Section: </B>16.1&#160;
 [cpp.cond]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>23 October 2006<BR>


<P>The description of preprocessing expressions in
16.1
 [cpp.cond] paragraph 4 says,</P>

<BLOCKQUOTE>

The resulting tokens comprise the controlling constant expression
which is evaluated according to the rules of 5.19 using arithmetic
that has at least the ranges specified in 18.2
 [support.limits],
except that all signed and unsigned integer types act as if they have
the same representation as, respectively, <TT>intmax_t</TT> or
<TT>uintmax_t</TT> (18.3.2).

</BLOCKQUOTE>

<P>However, this does not address the type implicitly assigned to
integral literals.  For example, in an implementation where <TT>int</TT>
is 32 bits and <TT>long long</TT> is 64 bits, is a literal like
<TT>0xffffffff</TT> signed or unsigned?  WG14 adopted
<A HREF="http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_265.htm">
DR 265</A> to deal with this issue in the essentially-identical
wording in C99; we should probably follow suit for C++.</P>

<P><B>Proposed Resolution (November, 2006):</B></P>

<P>Change 16.1
 [cpp.cond] paragraph 4 as follows:</P>

<BLOCKQUOTE>

...and then each preprocessing token is converted into a token. The
resulting tokens comprise the controlling constant expression which is
evaluated according to the rules of 5.19
 [expr.const] using
arithmetic that has at least the ranges specified in 18.2
 [support.limits]<S>, except that</S><B>. For the purposes of that token
conversion and evaluation</B> all signed and unsigned integer types
act as if they have the same representation as,
respectively, <TT>intmax_t</TT> or <TT>uintmax_t</TT> (18.3.2
 [stdinth])<B>[<I>Footnote:</I> Thus on an implementation where
<TT>std::numeric_limits&lt;int&gt;::max()</TT> is 0x7FFF and
<TT>std::numeric_limits&lt;unsigned int&gt;::max()</TT> is 0xFFFF,
the integer literal <TT>0x8000</TT> is signed and positive within a
<TT>#if</TT> expression even though it is unsigned in translation
phase 7 (2.1
 [lex.phases]). &#8212;<I>end footnote</I>]</B>.
This includes interpreting character literals...

</BLOCKQUOTE>

<BR><BR><HR><A NAME="626"></A><H4>626.
  
Preprocessor string literals
</H4><B>Section: </B>16.3.2&#160;
 [cpp.stringize]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Gennaro Prota
 &#160;&#160;&#160;

 <B>Date: </B>12 September 2006<BR>


<P>Clause 16
 [cpp] refers in several places to
&#8220;character string literals&#8221; without specifying
whether they are narrow or wide strings.  For instance, what kind
of string does the <TT>#</TT> operator (16.3.2
 [cpp.stringize]) produce?</P>

<P>16.4
 [cpp.line] paragraph 1 says,</P>

<BLOCKQUOTE>

The string literal of a <TT>#line</TT> directive, if present, shall be a
character string literal.

</BLOCKQUOTE>

<P>Is &#8220;character string literal&#8221; intended to mean a
narrow string literal?  (Also, there is no <I>string-literal</I>
mentioned in the grammatical descriptions of <TT>#line</TT>;
paragraph 4 reads,</P>

<P><UL><TT># line</TT> <I>digit-sequence</I> <TT>"</TT> <I>s-char-sequence<SUB>opt</SUB></I> <TT>"</TT> <I>new-line</I></UL></P>

<P>which is apparently intended to suggest a string literal but does
not use the term.)</P>

<P>16.8
 [cpp.predefined] should also specify what kind of
character string literals are produced by the various string-valued
predefined macros.</P>

<P><B>Notes from the July, 2007 meeting:</B></P>

<P>The CWG affirmed that all the string literals mentioned in
Clause 16
 [cpp] are intended to be narrow strings.</P>

<P><B>Proposed resolution (September, 2008)</B></P>

<OL>
<LI><P>Change the footnote in 16
 [cpp] paragraph 1 as
follows:
</P></LI>

<BLOCKQUOTE>

Thus, preprocessing directives are commonly called
&#8220;lines.&#8221; These &#8220;lines&#8221; have no other
syntactic significance, as all white space is equivalent except
in certain situations during preprocessing (see the <TT>#</TT>
<S>character</S> string literal creation operator in 16.3.2
 [cpp.stringize], for example).

</BLOCKQUOTE>

<LI><P>Change 16.3.2
 [cpp.stringize] paragraph 2 as follows:
</P></LI>

<BLOCKQUOTE>

If, in the replacement list, a parameter is immediately preceded
by a <TT>#</TT> preprocessing token, both are replaced by a
single <S>character</S> <B>ordinary</B> string literal
<B>(2.13.4
 [lex.string])</B> preprocessing token that
contains the spelling of the preprocessing token sequence for the
corresponding argument... Otherwise, the original spelling of
each preprocessing token in the argument is retained in the
<S>character</S> <B>ordinary</B> string literal, except for special
handling for producing the spelling of string literals and
character literals: a <TT>\</TT> character is inserted before
each <TT>"</TT> and <TT>\</TT> character of a character literal
or string literal (including the delimiting <TT>"</TT>
characters). If the replacement that results is not a valid
<S>character</S> <B>ordinary</B> string literal, the behavior is
undefined. The <S>character</S> <B>ordinary</B> string literal
corresponding to an empty argument is <TT>""</TT>. The order of
evaluation of <TT>#</TT> and <TT>##</TT> operators is
unspecified.

</BLOCKQUOTE>

<LI><P>Change 16.3.5
 [cpp.scope] paragraph 6 as follows:
</P></LI>

<BLOCKQUOTE>

To illustrate the rules for creating <S>character</S>
<B>ordinary</B> string literals and concatenating tokens, the
sequence... or, after concatenation of the <S>character</S>
<B>ordinary</B> string literals...

</BLOCKQUOTE>

<LI><P>Change 16.4
 [cpp.line] paragraph 1 as follows:
</P></LI>

<BLOCKQUOTE>

The string literal of a <TT>#line</TT> directive, if present,
shall be <S>a character</S> <B>an ordinary</B> string literal.

</BLOCKQUOTE>

<LI><P>Change 16.4
 [cpp.line] paragraph 4 as follows:
</P></LI>

<BLOCKQUOTE>

...and changes the presumed name of the source file to be the
contents of the <S>character</S> <B>ordinary</B> string literal.

</BLOCKQUOTE>

<LI><P>Change 16.8
 [cpp.predefined] paragraph 1 as follows:
</P></LI>

<BLOCKQUOTE>

<P>__DATE__</P>

<UL>The date of translation of the source file
(<S>a character</S> <B>an ordinary</B> string literal of the form...</UL>

<P>__FILE__</P>

<UL>The presumed name of the source file (<S>a character</S>
<B>an ordinary</B> string literal).</UL>

<P>...</P>

<P>__TIME__</P>

<UL>The time of translation of the source file (<S>a character</S>
<B>an ordinary</B> string literal of the form...</UL>

</BLOCKQUOTE>
</OL>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>The proposed resolution will be discussed with the C Committee
before proceeding, as it is expected that the next revision of the
C Standard will also adopt new forms of string literals.</P>

<BR><BR><BR><BR><HR><A NAME="Drafting Status"></A><H3>Issues with "Drafting" Status</H3>
<HR><A NAME="690"></A><H4>690.
  
The dynamic type of an rvalue reference
</H4><B>Section: </B>1.3&#160;
 [intro.defs]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Eelis van der Weegen
 &#160;&#160;&#160;

 <B>Date: </B>7 April, 2008<BR>


<P>According to 1.3
 [intro.defs], &#8220;dynamic type,&#8221;</P>

<BLOCKQUOTE>

The dynamic type of an rvalue expression is its static type.

</BLOCKQUOTE>

<P>This is not true of an rvalue reference, which can be bound
to an object of a class type derived from the reference's static
type.</P>

<P><B>Proposed resolution (June, 2008):</B></P>

<P>Change 1.3
 [intro.defs], &#8220;dynamic type,&#8221;
as follows:</P>

<BLOCKQUOTE>

the type of the most derived object (1.8
 [intro.object]) to
which <S>the lvalue denoted by</S> an lvalue <B>or an rvalue-reference
(clause 5
 [expr])</B> expression
refers. [<I>Example:</I> if a pointer (8.3.1
 [dcl.ptr])
<TT>p</TT> whose static type is &#8220;pointer to class
<TT>B</TT>&#8221; is pointing to an object of class <TT>D</TT>,
derived from <TT>B</TT> (clause 10
 [class.derived]), the dynamic
type of the expression <TT>*p</TT> is &#8220;D.&#8221; References
(8.3.2
 [dcl.ref]) are treated similarly. &#8212;<I>end
example</I>] The dynamic type of an rvalue expression <B>that is not an
rvalue reference</B> is its static type.

</BLOCKQUOTE>

<P><B>Notes from the June, 2008 meeting:</B></P>

<P>Because expressions have an rvalue reference type only fleetingly,
immediately becoming either lvalues or rvalues and no longer
references, the CWG expressed a desire for a different approach that
would somehow describe an rvalue that resulted from an rvalue
reference instead of using the concept of an expression that is an
rvalue reference, as above.  This approach could also be used in the
resolution of <A HREF="
     cwg_active.html#664">issue 664</A>.</P>

<P><B>Additional note (August, 2008):</B></P>

<P>This issue, along with <A HREF="
     cwg_active.html#664">issue 664</A>,
indicates that rvalue references have more in common with lvalues
than with other rvalues: they denote particular objects, thus
allowing object identity and polymorphic behavior.  That suggests
that these issues may be just the tip of the iceberg: restrictions
on out-of-lifetime access to objects, the aliasing rules, and many
other specifications are written to apply only to lvalues, on the
assumption that only lvalues refer to specific objects.  That
assumption is no longer valid with rvalue references.</P>

<P>This suggests that it might be better to classify all rvalue
references, not just named rvalue references, as lvalues instead
of rvalues, and then just change the reference binding, overload
resolution, and template argument deduction rules to cater to the
specific kind of lvalues that are associated with rvalue references.</P>

<BR><BR><HR><A NAME="612"></A><H4>612.
  
Requirements on a conforming implementation
</H4><B>Section: </B>1.9&#160;
 [intro.execution]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Clark Nelson
 &#160;&#160;&#160;

 <B>Date: </B>23 January 2007<BR>


<P>The execution requirements on a conforming implementation are
described twice in the Standard, once in 1.9
 [intro.execution]
paragraphs 5-6 and again in paragraph 11.  These descriptions differ
in at least a couple of important ways:</P>

<P>The most significant discrepancy has to do with the way output is
described. In paragraph 11, the least requirements are described in
terms of data written at program termination, clearly allowing
arbitrary buffering, whereas in paragraph 6, the observable behavior
is described in terms of calls to I/O functions.  For example, there
are compilers which transform a call to printf with a single argument
into a call to fputs.  That's valid under paragraph 11, but not under
paragraph 6.</P>

<P>Also, in paragraph 6, volatile accesses and I/O operations are
included in a single sequence, suggesting that they are equally
constrained by sequencing requirements, whereas in paragraph 11, they
are clearly not.</P>

<P>There are also editorial discrepancies that should be cleaned
up.</P>

<BR><BR><HR><A NAME="630"></A><H4>630.
  
Equality of narrow and wide character values in the basic character set
</H4><B>Section: </B>2.2&#160;
 [lex.charset]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Tom Plum
 &#160;&#160;&#160;

 <B>Date: </B>21 April 2007<BR>


<P>WG14 accepted
<A href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_279.htm">
DR 279</A> regarding the rule known colloquially as the
<TT>L'x'=='x'</TT> rule.  This change was made to C99 in TC2.  The
Austin Group subsequently opened
<A href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_321.htm">
DR 321</A> against TC2, observing that the change made in TC2 would
invalidate existing conforming C code that relied on the
<TT>L'x'=='x'</TT> rule.</P>

<P>DR 321 is now closed and will be included in the TC3 to C99.  This
change defines a new standard macro, which WG14 drafted as follows:</P>

<BLOCKQUOTE>

<TT>__STDC_MB_MIGHT_NEQ_WC__</TT>: The integer constant <TT>1</TT>,
intended to indicate that there might be some
character <TT>x</TT> in the basic character set, such
that <TT>'x'</TT> need not be equal to <TT>L'x'</TT>.

</BLOCKQUOTE>

<P>WG14 requests that WG21 adopt this revision and this macro in
C++0x.</P>

<BR><BR><HR><A NAME="369"></A><H4>369.
  
Are <TT>new</TT>/<TT>delete</TT> identifiers or <I>preprocessing-op-or-punc</I>?
</H4><B>Section: </B>2.4&#160;
 [lex.pptoken]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Martin v. Loewis
 &#160;&#160;&#160;

 <B>Date: </B>30 July 2002<BR>


<P>2.4
 [lex.pptoken] paragraph 2 specifies that there are 5
categories of tokens in phases 3 to 6. With 2.12
 [lex.operators]
paragraph 1, it is unclear whether <TT>new</TT> is an <I>identifier</I> or a
<I>preprocessing-op-or-punc</I>; likewise for <TT>delete</TT>. This is
relevant to answer the question whether</P>
<PRE>
#define delete foo
</PRE>
<P>is a well-formed control-line, since that requires an identifier 
after the <TT>define</TT> token.</P>

<P>(See also <A HREF="
     cwg_active.html#189">issue 189</A>.)</P>

<BR><BR><HR><A NAME="189"></A><H4>189.
  
Definition of <I>operator</I> and <I>punctuator</I>
</H4><B>Section: </B>2.12&#160;
 [lex.operators]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>20 Dec 1999<BR>





<P>The nonterminals <I>operator</I> and <I>punctuator</I> in
2.6
 [lex.token]
 are not defined.  There is
a definition of the nonterminal <I>operator</I> in
13.5
 [over.oper]
 paragraph 1, but it is
apparent that the two nonterminals are not the same: the latter
includes keywords and multi-token operators and does not include the
nonoverloadable operators mentioned in paragraph 3.</P>

<P>There is a definition of <I>preprocessing-op-or-punc</I> in
2.12
 [lex.operators]
, with the notation that</P>

<BLOCKQUOTE>
Each <I>preprocessing-op-or-punc</I> is converted to a single token in
translation phase 7 (2.1).
</BLOCKQUOTE>

However, this list doesn't distinguish between <I>operator</I>s and
<I>punctuator</I>s, it includes digraphs and keywords (can a given
<I>token</I> be both a <I>keyword</I> and an <I>operator</I> at the
same time?), etc.

<P><B>Suggested resolution:</B></P>

<BR><OL>
<LI>Change 13.5
 [over.oper]
 to use the term
<I>overloadable-operator</I>.</LI>

<LI>Change 2.6
 [lex.token]
 to use the term
<I>operator-token</I> instead of <I>operator</I> (since there are
operators that are keywords and operators that are composed of more
than one token).</LI>

<LI>Change 2.12
 [lex.operators]
 to define
the nonterminals <I>operator-token</I> and <I>punctuator</I>.</LI>
</OL>

<P><B>Additional note (April, 2005):</B></P>

<P>The resolution for this problem should also address the fact that
<TT>sizeof</TT> and <TT>typeid</TT> (and potentially others like
<TT>decltype</TT> that may be added in the future) are described in
some places as &#8220;operators&#8221; but are not listed in
13.5
 [over.oper] paragraph 3 among the operators that cannot be
overloaded.</P>

<P>(See also <A HREF="
     cwg_active.html#369">issue 369</A>.)</P>
<BR><BR><HR><A NAME="633"></A><H4>633.
  
Specifications for variables that should also apply to references
</H4><B>Section: </B>3&#160;
 [basic]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alisdair Meredith
 &#160;&#160;&#160;

 <B>Date: </B>17 May 2007<BR>


<P>There are a number of specifications in the Standard that should
also apply to references.  For example:</P>

<UL>
<LI><P>3
 [basic] paragraphs 3-4 indicate that a reference
cannot have a name because it is not an entity.  (See also
<A HREF="
     cwg_defects.html#485">issue 485</A>.)</P></LI>

<LI><P>3.4.1
 [basic.lookup.unqual] paragraph 13 covers unqualified
lookup in the initializer of a variable member of a namespace but not
that of a reference member of a namespace.  It would be very strange
if the lookup in these two cases were different.</P></LI>

<LI><P>3.5
 [basic.link] paragraph 8 prohibits use of a type
without linkage as the type of a variable with linkage, but not as the
type of a reference with linkage.  (References with linkage are
explicitly mentioned earlier in the section.)</P></LI>

<LI><P>3.7.1
 [basic.stc.static] paragraph 3 permits local static
variables but not local static references.</P></LI>

</UL>

<P>A number of other examples could be cited.  A thorough review
is needed to make sure that references are completely
specified.</P>

<P><B>Proposed resolution (March, 2008):</B></P>

<OL>
<LI><P>Change 2.1
 [lex.phases] paragraph 1, number 9 as
follows:</P></LI>

<OL><LI VALUE="9"><P>All external <S>object and function</S>
<B>entity</B> references are resolved. Library components are linked
to satisfy external references to <S>functions and objects</S>
<B>entities</B> not defined in the current
translation...</P></LI></OL>

<LI><P>Change 3.3
 [basic.scope] paragraph 4, bullet 2 as
follows:</P></LI>

<UL><LI><P>exactly one declaration shall declare a class name or
enumeration name that is not a typedef name and the other
declarations shall all refer to the same object<B>,
reference,</B> or enumerator, or all refer to functions and
function templates...</P></LI></UL>

<LI><P>Change 3.3.1
 [basic.scope.pdecl] paragraph 9 as follows:</P></LI>

<BLOCKQUOTE>

Function declarations at block scope and object <B>or
reference</B> declarations with the <TT>extern</TT> specifier at
block scope refer to declarations that are members of an enclosing
namespace...

</BLOCKQUOTE>

<LI><P>Change 3.3.10
 [basic.scope.hiding] paragraph 2 as follows:</P></LI>

<BLOCKQUOTE>

A class name (9.1
 [class.name]) or enumeration name
(7.2
 [dcl.enum]) can be hidden by the name of an
object, <B>reference,</B> function, or enumerator declared in the
same scope. If a class or enumeration name and an object,
<B>reference,</B> function, or enumerator are declared in the
same scope (in any order) with the same name, the class or
enumeration name is hidden wherever the object, <B>reference,</B>
function, or enumerator name is visible.

</BLOCKQUOTE>

<LI><P>Change 3.4.1
 [basic.lookup.unqual] paragraph 14 as follows:
</P></LI>

<BLOCKQUOTE>

If a variable <B>or reference</B> member of a namespace is
defined outside of the scope of its namespace then any name <S>used</S>
<B>that appears</B> in the definition of the <S>variable</S> member
(after the <I>declarator-id</I>) is looked up as if the definition of
the <S>variable</S> member occurred in its namespace...

</BLOCKQUOTE>

<LI><P>Change 3.4.3
 [basic.lookup.qual] paragraph 1 as follows:</P></LI>

<BLOCKQUOTE>

...During the lookup for a name preceding the <TT>::</TT> scope
resolution operator, object, <B>reference,</B> function, and
enumerator names are ignored...

</BLOCKQUOTE>

<LI><P>Change 3.4.3.2
 [namespace.qual] paragraph 5 as follows:</P></LI>

<BLOCKQUOTE>

During the lookup of a qualified namespace member name, if the
lookup finds more than one declaration of the member, and if one
declaration introduces a class name or enumeration name and the
other declarations either introduce the same object, <B>the same
reference,</B> the same enumerator or a set of functions, the
non-type name hides the class or enumeration name if and only if
the declarations are from the same namespace; otherwise (the
declarations are from different namespaces), the program is
ill-formed.

</BLOCKQUOTE>

<LI><P>Change 3.5
 [basic.link] paragraph 6 as follows:</P></LI>

<BLOCKQUOTE>

The name of a function declared in block scope, and the name of
an object <B>or reference</B> declared by a block scope
<TT>extern</TT> declaration, have linkage...

</BLOCKQUOTE>

<LI><P>Change 3.5
 [basic.link] paragraph 8 as follows:
</P></LI>

<BLOCKQUOTE>

...A type without linkage shall not be used as the type of a
variable<B>, reference,</B> or function with linkage, unless <S>the
variable or function</S> <B>that entity</B> has extern "C" linkage...

</BLOCKQUOTE>

<LI><P>Change 3.5
 [basic.link] paragraph 10 as follows:</P></LI>

<BLOCKQUOTE>

...the types specified by all declarations referring to a given
object<B>, reference,</B> or function shall be identical...

</BLOCKQUOTE>

<LI><P>Change 3.6.1
 [basic.start.main] paragraph 1 as follows:</P></LI>

<BLOCKQUOTE>

...Dynamic initialization of an object <B>or reference</B> is either
ordered or unordered.  Definitions of explicitly specialized
class template static data members have ordered
initialization. Other class template static data members (i.e.,
implicitly or explicitly instantiated specializations) have
unordered initialization.  Other objects <B>and references</B>
defined in namespace scope have ordered initialization. Objects
<B>and references</B> defined within a single translation unit
and with ordered initialization shall be initialized in the order
of their definitions in the translation unit. The order of
initialization is unspecified for objects <B>and references</B>
with unordered initialization and for objects <B>and
references</B> defined in different translation units. An
unordered initialization is indeterminately sequenced with
respect to every other dynamic initialization. [<I>Note:</I>
8.5.1
 [dcl.init.aggr] describes the order in which aggregate
members are initialized. The initialization of local static
objects <B>and references</B> is described in 6.7
 [stmt.dcl]. &#8212;<I>end note</I>]

</BLOCKQUOTE>

<LI><P>Change 3.6.1
 [basic.start.main] paragraph 3 as follows:</P></LI>

<BLOCKQUOTE>

It is implementation-defined whether or not the dynamic
initialization (8.5
 [dcl.init], 9.4
 [class.static], 12.1
 [class.ctor], 12.6.1
 [class.expl.init]) of an object <B>or reference</B> of namespace
scope is done before the first statement of <TT>main</TT>. If the
initialization is deferred to some point in time after the first
statement of <TT>main</TT>, it shall occur before the first use
of any function<B>,</B> <S>or</S> object<B>, or reference</B>
defined in the same translation unit as the object <B>or
reference</B> to be initialized. [<I>Footnote:</I> An object
<B>or reference</B> defined in namespace scope having
initialization with side-effects must be initialized even if it
is not used (3.7.1). &#8212;<I>end footnote</I>]

</BLOCKQUOTE>

<LI><P>Change 3.7.1
 [basic.stc.static] paragraph 3 as follows:
</P></LI>

<BLOCKQUOTE>

The keyword <TT>static</TT> can be used to declare a local variable
<B>or reference</B> with static storage duration. [<I>Note:</I>
6.7
 [stmt.dcl] describes <S>the</S> <B>their</B>
initialization <S>of local <TT>static</TT> variables</S>; 3.6.3
 [basic.start.term] describes <S>the</S> <B>their</B> destruction <S>of
local <TT>static</TT> variables</S>. &#8212;<I>end note</I>]

</BLOCKQUOTE>

<LI><P>Change 5.1
 [expr.prim] paragraph 4 as follows:
</P></LI>

<BLOCKQUOTE>

...The result is an lvalue if the entity is a function<B>,</B>
<S>or</S> variable<B>, or reference</B>... [<I>Note:</I> the use of
<TT>::</TT> allows <S>a type, an object, a function, an enumerator, or
a namespace</S> <B>an entity</B> declared in the global namespace to
be referred to even if its <S>identifier</S> <B>name</B> has been
hidden (3.4.3
 [basic.lookup.qual]). &#8212;<I>end note</I>]

</BLOCKQUOTE>

<LI><P>Change 5.1
 [expr.prim] paragraph 7 as follows:</P></LI>

<BLOCKQUOTE>

...The result is an lvalue if the entity is a function, variable,
<B>reference,</B> or data member.

</BLOCKQUOTE>

<LI><P>Change 5.1
 [expr.prim] paragraph 8 as follows:</P></LI>

<BLOCKQUOTE>

...The result is an lvalue if the member is a function<B>,</B> <S>or
a</S> variable<B>, or reference</B>.

</BLOCKQUOTE>

<LI><P>Change 6.5.1
 [stmt.while] paragraph 2 as follows:</P></LI>

<BLOCKQUOTE>

...The object <B>or reference</B> created in a condition is
destroyed and created with each iteration of the loop...

</BLOCKQUOTE>

<LI><P>Change 6.7
 [stmt.dcl] paragraph 2 as follows:</P></LI>

<BLOCKQUOTE>

Variables <B>and references</B> with automatic storage duration
(3.7.3
 [basic.stc.auto]) are initialized each time their
<I>declaration-statement</I> is executed...

</BLOCKQUOTE>

<LI><P>Change 6.7
 [stmt.dcl] paragraph 3 as follows:</P></LI>

<BLOCKQUOTE>

...A program that jumps from a point where a local variable <B>or
reference</B> with automatic storage duration is not in scope to a
point where it is in scope is ill-formed unless <S>the variable
has</S> <B>it is a variable with</B> trivial type (3.9
 [basic.types]) and is declared without an <I>initializer</I>
(8.5
 [dcl.init])...

</BLOCKQUOTE>

<LI><P>Change 6.7
 [stmt.dcl] paragraph 4 as follows:</P></LI>

<BLOCKQUOTE>

The zero-initialization (8.5
 [dcl.init]) of all local
objects with static storage duration (3.7.1
 [basic.stc.static])
is performed before any other initialization takes place.
<B>When initialized with a constant expression, a local reference
with static storage duration or a</B> <S>A</S> local object of
trivial or literal type (3.9
 [basic.types]) with static
storage duration <S>initialized with
<I>constant-expression</I>s</S> is initialized before its block
is first entered. An implementation is permitted to perform early
initialization of other local objects with static storage
duration under the same conditions that an implementation is
permitted to statically initialize an object with static storage
duration in namespace scope (3.6.2
 [basic.start.init]).
Otherwise such an object <B>or reference</B> is initialized the
first time control passes through its declaration; such an object
<B>or reference</B> is considered initialized upon the completion
of its initialization. If the initialization exits by throwing an
exception, the initialization is not complete, so it will be
tried again the next time control enters the declaration. If
control re-enters the declaration (recursively) while the object
<B>or reference</B> is being initialized, the behavior is
undefined...

</BLOCKQUOTE>

<LI><P>Change 7.1.1
 [dcl.stc] paragraphs 2-7 as follows:</P></LI>

<BLOCKQUOTE>

<P>The <TT>register</TT> specifier shall be applied only to names
of objects <B>and references</B> declared in a block
(6.3
 [stmt.block]) or to function parameters
(8.4
 [dcl.fct.def]). It specifies that the named object
<B>or reference</B> has automatic storage duration (3.7.3
 [basic.stc.auto]). An object <B>or reference</B> declared without a
<I>storage-class-specifier</I> at block scope or declared as a
function parameter has automatic storage duration by default.</P>

<P>A <TT>register</TT> specifier is a hint to the implementation
that the object <B>or reference</B> so declared will be heavily
used. [<I>Note:</I> the hint can be ignored and in most
implementations it will be ignored if the address of the object
is taken. &#8212;<I>end note</I>]</P>

<P>The <TT>static</TT> specifier can be applied only to names of
objects<B>, references,</B> and functions and to anonymous unions
(9.5
 [class.union]). There can be no <TT>static</TT>
function declarations within a block, nor any <TT>static</TT>
function parameters. A <TT>static</TT> specifier used in the
declaration of an object <B>or reference</B> declares the
<S>object</S> <B>entity</B> to have static storage duration
(3.7.1
 [basic.stc.static]). A <TT>static</TT> specifier can be
used in declarations of class members; 9.4
 [class.static]
describes its effect. For the linkage of a name declared with a
static specifier, see 3.5
 [basic.link].</P>

<P>The <TT>extern</TT> specifier can be applied only to the names
of objects<B>, references,</B> and functions. The <TT>extern</TT>
specifier cannot be used in the declaration of class members or
function parameters. For the linkage of a name declared with an
<TT>extern</TT> specifier, see 3.5
 [basic.link].
[<I>Note:</I> The <TT>extern</TT> keyword can also be used in
<I>explicit-instantiation</I>s and <I>linkage-specification</I>s,
but it is not a <I>storage-class-specifier</I> in such contexts.
&#8212;<I>end note</I>]</P>

<P>A name declared in a namespace scope without a
<I>storage-class-specifier</I> has external linkage unless it has
internal linkage because of a previous declaration and provided
it is not declared <TT>const</TT>. Objects declared
<TT>const</TT> and not explicitly declared <TT>extern</TT> have
internal linkage.</P>

<P>The linkages implied by successive declarations for a given
entity shall agree. That is, within a given scope, each
declaration declaring the same object <B>or reference</B> name or
the same overloading of a function name shall imply the same
linkage.  Each function in a given set of overloaded functions
can have a different linkage, however...</P>

</BLOCKQUOTE>

<LI><P>Change 7.1.6.4
 [dcl.spec.auto] paragraph 1 as follows:
</P></LI>

<BLOCKQUOTE>

The <TT>auto</TT> <I>type-specifier</I> signifies that the type of an object
<B>or reference</B> being declared shall be deduced from its
initializer...

</BLOCKQUOTE>

<LI><P>Change 7.1.6.4
 [dcl.spec.auto] paragraph 3 as follows:
</P></LI>

<BLOCKQUOTE>

Otherwise, the type of the object <B>or reference</B> is deduced
from its initializer. The name of the <S>object</S> <B>entity</B>
being declared shall not appear in the initializer
expression. This use of <TT>auto</TT> is allowed when declaring
objects <B>and references</B> in a block (6.3
 [stmt.block]), in namespace scope (3.3.5
 [basic.scope.namespace]),
and in a <I>for-init-statement</I> (6.5.3
 [stmt.for]).

</BLOCKQUOTE>

<LI><P>Change 7.1.6.4
 [dcl.spec.auto] paragraph 4 as follows:
</P></LI>

<BLOCKQUOTE>

The <TT>auto</TT> <I>type-specifier</I> can also be used in
declaring an object <B>or reference</B> in the <I>condition</I>
of a selection statement...

</BLOCKQUOTE>

<LI><P>Change 7.1.6.4
 [dcl.spec.auto] paragraphs 6-7 as
follows:</P></LI>

<BLOCKQUOTE>

<P>Once the type of a <I>declarator-id</I> has been determined
according to 8.3
 [dcl.meaning], the type of the declared
variable <B>or reference</B> using the <I>declarator-id</I> is
determined from the type of its initializer using the rules for
template argument deduction. Let <TT>T</TT> be the type that has
been determined for a variable <B>or reference</B> identifier
<TT>d</TT>. Obtain <TT>P</TT> from <TT>T</TT> by replacing the
occurrences of <TT>auto</TT> with a new invented type template
parameter <TT>U</TT>. Let <TT>A</TT> be the type of the
initializer expression for <TT>d</TT>. The type deduced for
<S>the variable</S> <TT>d</TT> is then the deduced type
determined using the rules of template argument deduction from a
function call (14.8.2.1
 [temp.deduct.call]), where <TT>P</TT>
is a function template parameter type and <TT>A</TT> is the
corresponding argument type. If the deduction fails, the
declaration is ill-formed.</P>

<P>If the list of declarators contains more than one declarator,
the type of each declared <S>variable</S> <B>entity</B> is
determined as described above...</P>

</BLOCKQUOTE>

<LI><P>Change 7.3.1.1
 [namespace.unnamed] paragraph 2 as follows:
</P></LI>

<BLOCKQUOTE>

The use of the <TT>static</TT> keyword is deprecated when
declaring objects <B>and references</B> in a namespace scope (see
annex D
 [depr]); the <I>unnamed-namespace</I>
provides a superior alternative.

</BLOCKQUOTE>

<LI><P>Change 7.3.4
 [namespace.udir] paragraph 6 as follows:
</P></LI>

<BLOCKQUOTE>

...[<I>Note:</I> in particular, the name of an object,
<B>reference,</B> function or enumerator does not hide the name
of a class or enumeration declared in a different namespace...

</BLOCKQUOTE>

<LI><P>Change 8
 [dcl.decl] paragraph 1 as follows:</P></LI>

<BLOCKQUOTE>

A declarator declares a single object, <B>reference,</B>
function, or type, within a declaration...

</BLOCKQUOTE>

<LI><P>Change 8
 [dcl.decl] paragraph 2 as follows:</P></LI>

<BLOCKQUOTE>

...The specifiers indicate the type, storage class or other
properties of the <S>objects, functions or typedefs</S>
<B>entities</B> being declared. The declarators specify the names
of these <S>objects, functions or typedefs,</S> <B>entities</B>
and (optionally) modify the type of the specifiers with operators
such as <TT>*</TT> (pointer to) and <TT>()</TT> (function
returning)...

</BLOCKQUOTE>

<LI><P>Change 8.1
 [dcl.name] paragraph 1 as follows:
</P></LI>

<BLOCKQUOTE>

...This can be done with a <I>type-id</I>, which is syntactically
a declaration for an object<B>, reference,</B> or function of
that type that omits the name of the <S>object or function</S>
<B>entity</B>...

</BLOCKQUOTE>

<LI><P>Change 8.5
 [dcl.init] paragraph 2 as follows:
</P></LI>

<BLOCKQUOTE>

Automatic, register, static, and external variables <B>and
references</B> of namespace scope can be initialized by arbitrary
expressions involving literals and previously declared variables
and functions...

</BLOCKQUOTE>

<LI><P>Change 8.5
 [dcl.init] paragraph 4 as follows:
</P></LI>

<BLOCKQUOTE>

The order of initialization of static objects <B>and
references</B> is described in 3.6
 [basic.start] and
6.7
 [stmt.dcl].

</BLOCKQUOTE>

<LI><P>Delete the last bullet of 8.5
 [dcl.init]
paragraph 4, first list (zero-initialization) and replace the
semicolon with a period in the preceding bullet:</P></LI>

<UL><LI><P><S>if T is a reference type, no initialization is
performed.</S></P></LI></UL>

<LI><P>Change 8.5.3
 [dcl.init.ref] paragraph 1 as follows:
</P></LI>

<BLOCKQUOTE>

<S>A variable</S> <B>An entity</B> declared to be a
<TT>T&amp;</TT> or <TT>T&amp;&amp;</TT>, that is,
&#8220;reference to type <TT>T</TT>&#8221; (8.3.2
 [dcl.ref]), shall be initialized by an object, or function,
of type <TT>T</TT> or by an object that can be converted into a
<TT>T</TT>...

</BLOCKQUOTE>

<LI><P>Change 9.1
 [class.name] paragraph 2 as follows:
</P></LI>

<BLOCKQUOTE>

...If a class name is declared in a scope where an object,
<B>reference,</B> function, or enumerator of the same name is
also declared, then when both declarations are in scope, the
class can be referred to only using an
<I>elaborated-type-specifier</I> (3.4.4
 [basic.lookup.elab])...

</BLOCKQUOTE>

<LI><P>Change 9.4.2
 [class.static.data] paragraph 6 as follows:
</P></LI>

<BLOCKQUOTE>

<TT>Static</TT> data members are initialized and destroyed
exactly like non-local objects <B>and references</B>
(3.6.2
 [basic.start.init], 3.6.3
 [basic.start.term]).

</BLOCKQUOTE>

<LI><P>Change 9.8
 [class.local] paragraph 1 as follows:
</P></LI>

<BLOCKQUOTE>

...Declarations in a local class can use only type names,
<S>static</S> variables <B>and references with static storage
duration</B>, <S><TT>extern</TT> variables and</S> functions, and
enumerators from the enclosing scope...

</BLOCKQUOTE>

<LI><P>Change 10.2
 [class.member.lookup] paragraph 4 as follows:
</P></LI>

<BLOCKQUOTE>

...[<I>Note:</I> Looking up a name in an
<I>elaborated-type-specifier</I> (3.4.4
 [basic.lookup.elab]) or
<I>base-specifier</I> (clause 10
 [class.derived]), for
instance, ignores all non-type declarations, while looking up a
name in a <I>nested-name-specifier</I> (3.4.3
 [basic.lookup.qual]) ignores function, object, <B>reference,</B> and
enumerator declarations...

</BLOCKQUOTE>

<LI><P>Change 14
 [temp] paragraph 5 as follows:
</P></LI>

<BLOCKQUOTE>

A class template shall not have the same name as any other
template, class, function, object, <B>reference,</B> enumeration,
enumerator, namespace, or type in the same scope...

</BLOCKQUOTE>

<LI><P>Change 14.8
 [temp.fct.spec] paragraph 2 as follows:
</P></LI>

<BLOCKQUOTE>

Each function template specialization instantiated from a
template has its own copy of any static variable <B>or
reference</B>...

</BLOCKQUOTE>

</OL>

<P><I>[Drafting notes: This resolution depends on the part of the
resolution for <A HREF="
     cwg_defects.html#485">issue 485</A> that adds
references to the list of &#8220;entities.&#8221; It is also
partly resolved by the proposed resolution for <A HREF="
     cwg_active.html#570">issue 570</A>. No change is proposed to the text in
7.5
 [dcl.link], hence reference names continue to have
no language linkage, and prohibitions against conflicting linkage
specifications do not apply to reference declarations.]</I></P>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>The CWG expressed interest in an approach that would define
&#8220;variable&#8221; to include both objects and references and
to use that for both this issue and <A HREF="
     cwg_active.html#570">issue 570</A>.</P>

<BR><BR><HR><A NAME="676"></A><H4>676.
  
<I>static_assert-declaration</I>s and general requirements for declarations
</H4><B>Section: </B>3.1&#160;
 [basic.def]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alisdair Meredith
 &#160;&#160;&#160;

 <B>Date: </B>12 February, 2008<BR>


<P>3.1
 [basic.def] makes statements about declarations that do
not appear to apply to <I>static_assert-declaration</I>s.  For example,
paragraph 1 says,</P>

<BLOCKQUOTE>

A declaration (clause 7
 [dcl.dcl]) introduces names into a
translation unit or redeclares names introduced by previous
declarations.  A declaration specifies the interpretation and
attributes of these names.

</BLOCKQUOTE>

<P>What name is being declared or described by
a <I>static_assert-declaration</I>?</P>

<P>Also, paragraph 2 lists the kinds of declarations that are not
definitions, and a <I>static_assert-declaration</I> is not among them.
Is it intentional that <I>static_assert-declaration</I>s are
definitions?</P>

<BR><BR><HR><A NAME="570"></A><H4>570.
  
Are references subject to the ODR?
</H4><B>Section: </B>3.2&#160;
 [basic.def.odr]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Dave Abrahams
 &#160;&#160;&#160;

 <B>Date: </B>2 April 2006<BR>




<P>3.2
 [basic.def.odr] paragraph 1 says,</P>

<BLOCKQUOTE>

No translation unit shall contain more than one definition of any
variable, function, class type, enumeration type or template.

</BLOCKQUOTE>

<P>This says nothing about references.  Is it permitted to define a
reference more than once in a single translation unit?  (The list in
paragraph 5 of things that can have definitions in multiple translation
units does not include references.)</P>

<P><B>Proposed resolution (March, 2008):</B></P>

<OL>
<LI><P>Change 3.2
 [basic.def.odr] paragraph 1 as follows:
</P></LI>

<BLOCKQUOTE>

No translation unit shall contain more than one definition of any
variable, <B>reference,</B> function, class type, enumeration
type or template.

</BLOCKQUOTE>

<LI><P>Change 3.2
 [basic.def.odr] paragraph 2 as follows:
</P></LI>

<BLOCKQUOTE>

...An object<B>, reference,</B> or non-overloaded function whose
name appears as a potentially-evaluated expression is used unless
it is an object that satisfies the requirements for appearing in
a constant expression...

</BLOCKQUOTE>

<LI><P>Change 3.2
 [basic.def.odr] paragraph 3 as follows:
</P></LI>

<BLOCKQUOTE>

Every program shall contain exactly one definition of every
non-inline function<B>,</B> <S>or</S> object<B>, or reference</B>
that is used in that program...

</BLOCKQUOTE>

</OL>

<P><I>(Note: this resolution also resolves part of
<A HREF="
     cwg_active.html#633">issue 633</A>.)</I></P>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>The CWG expressed interest in an approach that would define
&#8220;variable&#8221; to include both objects and references and
to use that for both this issue and <A HREF="
     cwg_active.html#633">issue 633</A>.</P>

<BR><BR><HR><A NAME="678"></A><H4>678.
  
Language linkage of member function parameter types and the ODR
</H4><B>Section: </B>3.2&#160;
 [basic.def.odr]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Widman
 &#160;&#160;&#160;

 <B>Date: </B>15 February, 2008<BR>




<P>I thought this case would result in undefined behavior according to
3.2
 [basic.def.odr]:</P>

<PRE>
    // t.h:
    struct A { void (*p)(); };

    // t1.cpp:
    #include "t.h" // A::p<SPAN STYLE="font-family:Times"><I> is a pointer to C++ func</I></SPAN>

    // t2.cpp:
    extern "C" {
    #include "t.h" // A::p<SPAN STYLE="font-family:Times"><I> is a pointer to C func</I></SPAN>
    }
</PRE>

<P>...but I don't see how any of the bullets in the list in paragraph
5 apply.</P>

<BR><BR><HR><A NAME="642"></A><H4>642.
  
Definition and use of &#8220;block scope&#8221; and &#8220;local scope&#8221;
</H4><B>Section: </B>3.3.2&#160;
 [basic.scope.local]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alisdair Meredith
 &#160;&#160;&#160;

 <B>Date: </B>6 Aug 2007<BR>


<P>The Standard uses the terms &#8220;block scope&#8221; and &#8220;local
scope&#8221; interchangeably, but the former is never formally
defined.  Would it be better to use only one term consistently?
&#8220;Block scope&#8221; seems to be more frequently used.</P>

<P><B>Notes from the October, 2007 meeting:</B></P>

<P>The CWG expressed a preference for the term &#8220;local
scope.&#8221;</P>

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

<OL>
<LI><P>Change the note in 3.3.1
 [basic.scope.pdecl] paragraph 9 as
follows:</P></LI>

<BLOCKQUOTE>

[<I>Note:</I> friend declarations refer to functions or classes
that are members of the nearest enclosing namespace, but they do
not introduce new names into that namespace (7.3.1.2
 [namespace.memdef]). Function declarations at <S>block</S>
<B>local</B> scope and object declarations with the
<TT>extern</TT> specifier at <S>block</S> <B>local</B> scope
refer to declarations that are members of an enclosing namespace,
but they do not introduce new names into that
scope. &#8212;<I>end note</I>]

</BLOCKQUOTE>

<LI><P>Change the example in 3.4.1
 [basic.lookup.unqual] paragraph 6
as follows:</P></LI>

<BLOCKQUOTE>

...<BR>
<TT>//</TT> <I>1) outermost <S>block</S> <B>local</B> scope of</I> <TT>A::n::f</TT><I>, before the use of</I> <TT>i</TT><BR>
...

</BLOCKQUOTE>

<LI><P>Change the example in 3.4.1
 [basic.lookup.unqual] paragraph 8
as follows:</P></LI>

<BLOCKQUOTE>

...<BR>
<TT>//</TT> <I>1) outermost <S>block</S> <B>local</B> scope of</I> <TT>M::N::X::f</TT><I>, before the use of</I> <TT>i</TT><BR>
...

</BLOCKQUOTE>

<LI><P>Change 3.4.1
 [basic.lookup.unqual] paragraph 11 as follows:
</P></LI>

<BLOCKQUOTE>

During the lookup for a name used as a default argument
(8.3.6
 [dcl.fct.default]) in a function
<I>parameter-declaration-clause</I> or used in the expression of a
<I>mem-initializer</I> for a constructor (12.6.2
 [class.base.init]), the function parameter names are visible and
hide the names of entities declared in the <S>block</S>
<B>local</B>, class or namespace scopes containing the function
declaration...

</BLOCKQUOTE>

<LI><P>Change 3.4.1
 [basic.lookup.unqual] paragraph 12 as follows:
</P></LI>

<BLOCKQUOTE>

During the lookup of a name used in the <I>constant-expression</I> of an
<I>enumerator-definition</I>, previously declared
<I>enumerator</I>s of the enumeration are visible and hide the
names of entities declared in the <S>block</S> <B>local</B>,
class, or namespace scopes containing the <I>enum-specifier</I>.

</BLOCKQUOTE>

<LI><P>Change 3.4.2
 [basic.lookup.argdep] paragraph 3 as follows:
</P></LI>

<BLOCKQUOTE>

<P>Let <I>X</I> be the lookup set produced by unqualified lookup
(3.4.1
 [basic.lookup.unqual]) and let <I>Y</I> be the lookup set
produced by argument dependent lookup (defined as follows). If
<I>X</I> contains</P>

<UL>
<LI><P>a declaration of a class member, or</P></LI>

<LI><P>a <S>block</S> <B>local</B>-scope function declaration
that is not a <I>using-declaration</I>, or</P></LI>

<LI><P>a declaration that is neither a function or a function
template</P></LI>

</UL>

<P>then <I>Y</I> is empty. Otherwise...</P>

</BLOCKQUOTE>

<LI><P>Change 3.5
 [basic.link] paragraph 6 as follows:
</P></LI>

<BLOCKQUOTE>

The name of a function declared in <S>block</S> <B>local</B>
scope, and the name of an object declared by a <S>block</S>
<B>local</B> scope <TT>extern</TT> declaration, have linkage. If
there is a visible declaration of an entity with linkage having
the same name and type, ignoring entities declared outside the
innermost enclosing namespace scope, the <S>block</S>
<B>local</B> scope declaration declares that same entity and
receives the linkage of the previous declaration. If there is
more than one such matching entity, the program is ill-formed.
Otherwise, if no matching entity is found, the <S>block</S>
<B>local</B> scope entity receives external linkage...

</BLOCKQUOTE>

<LI><P>Change 3.5
 [basic.link] paragraph 7 as follows:
</P></LI>

<BLOCKQUOTE>

When a <S>block</S> <B>local</B> scope declaration of an entity
with linkage is not found to refer to some other declaration,
then that entity is a member of the innermost enclosing
namespace...

</BLOCKQUOTE>

<LI><P>Change 3.6.3
 [basic.start.term] paragraph 1 as follows:
</P></LI>

<BLOCKQUOTE>

Destructors (12.4
 [class.dtor]) for initialized objects
of static storage duration (declared at <S>block</S> <B>local</B>
scope or at namespace scope) are called as a result...

</BLOCKQUOTE>

<LI><P>Change 7.1.1
 [dcl.stc] paragraph 2 as follows:
</P></LI>

<BLOCKQUOTE>

...An object declared without a <I>storage-class-specifier</I> at
<S>block</S> <B>local</B> scope or declared as a function
parameter has automatic storage duration by default.

</BLOCKQUOTE>

<LI><P>Change 7.1.2
 [dcl.fct.spec] paragraph 3 as follows
(cf 7.1.6.4
 [dcl.spec.auto] paragraph 3):
</P></LI>

<BLOCKQUOTE>

...The <TT>inline</TT> specifier shall not appear <S>on a block scope
function declaration</S> <B>when declaring a function in a block</B>...

</BLOCKQUOTE>

<LI><P>Change 9.5
 [class.union] paragraph 3 as follows:</P></LI>

<BLOCKQUOTE>

Anonymous unions declared in a named namespace or in the global
namespace shall be declared <TT>static</TT>. Anonymous unions
declared <S>at block scope</S> <B>in a block</B> shall be
declared with any storage class allowed for a <S>block</S>
<B>local</B>-scope variable, or with no storage class...

</BLOCKQUOTE>

<LI><P>Change 20.8.12
 [unique.ptr] paragraph 1 as follows:
</P></LI>

<BLOCKQUOTE>

<S>Template</S> <B>The class template</B> <TT>unique_ptr</TT>
stores a pointer to an object and deletes that object using the
associated deleter when it is itself destroyed (such as when
leaving <S>block</S> <B>local</B> scope (6.7
 [stmt.dcl])).

</BLOCKQUOTE>

<LI><P>Change 30.3.3
 [thread.lock] paragraph 1 as follows:
</P></LI>

<BLOCKQUOTE>

A <I>lock</I> is an object that holds a reference to a mutex and may
unlock the mutex during the lock's destruction (such as when
leaving <S>block</S> <B>local</B> scope)...

</BLOCKQUOTE>

<LI><P>Change Appendix B
 [implimits] paragraph 2,
bullet 8 as follows:</P></LI>

<UL><LI><P>Identifiers with <S>block</S> <B>local</B> scope
declared in one block [1 024].</P></LI></UL>

<LI><P>Change C.1.7
 [diff.class], reference to
9.1
 [class.name] as follows:</P></LI>

<BLOCKQUOTE>

...If the hidden name is at <S>block</S> <B>local</B> scope,
either the type or the struct tag has to be renamed.

</BLOCKQUOTE>

<LI><P>Change D.9.1
 [auto.ptr] paragraph 1 as follows:
</P></LI>

<BLOCKQUOTE>

Template <TT>auto_ptr</TT> stores a pointer to an object obtained
via <TT>new</TT> and deletes that object when it itself is
destroyed (such as when leaving <S>block</S> <B>local</B> scope
6.7
 [stmt.dcl]).

</BLOCKQUOTE>

</OL>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>Reevaluating the relative prevalence of the two terms
(including the fact that new uses of &#8220;block scope&#8221;
are being introduced, e.g., in both the lambda and thread-local
wording) led to CWG reversing its previous preference for
&#8220;local scope.&#8221;  The resolution will need to add a
definition of &#8220;block scope&#8221; and should change the
title of 3.3.2
 [basic.scope.local].</P>

<BR><BR><HR><A NAME="490"></A><H4>490.
  
Name lookup in friend declarations
</H4><B>Section: </B>3.4.1&#160;
 [basic.lookup.unqual]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Ben Hutchings
 &#160;&#160;&#160;

 <B>Date: </B>7 Dec 2004<BR>


<P>When 3.4.1
 [basic.lookup.unqual] paragraph 10 says,</P>

<BLOCKQUOTE>

In a <TT>friend</TT> declaration naming a member function, a name used in
the function declarator and not part of a <I>template-argument</I> in a
<I>template-id</I> is first looked up in the scope of the member
function's class. If it is not found, or if the name is part of a
<I>template-argument</I> in a <I>template-id</I>, the look up is
as described for unqualified names in the definition of the class
granting friendship.

</BLOCKQUOTE>

<P>what does &#8220;in the scope of the member function's
class&#8221; mean?  Does it mean that only members of the class
and its base classes are considered?  Or does it mean that the
same lookup is to be performed as if the name appeared in the
member function's class?  Implementations vary in this regard.
For example:</P>

<PRE>
     struct s1;

     namespace ns {
         struct s1;
     }

     struct s2 {
         void f(s1 &amp;);
     };

     namespace ns {
         struct s3 {
             friend void s2::f(s1 &amp;);
         };
     }
</PRE>

<P>Microsoft Visual C++ and Comeau C++ resolve <TT>s1</TT> in the
friend declaration to <TT>ns::s1</TT> and issue an error, while
g++ resolves it to <TT>::s1</TT> and accepts the code.</P>

<P><B>Notes from the April, 2005 meeting:</B></P>

<P>The phrase &#8220;looked up in the scope of [a] class&#8221; occurs
frequently throughout the Standard and always refers to the member name
lookup described in 10.2
 [class.member.lookup].  This is the first
interpretation mentioned above (&#8220;only members of the class and its
base classes&#8221;), resolving <TT>s1</TT> to <TT>ns::s1</TT>.  A
cross-reference to 10.2
 [class.member.lookup] will be added to
3.4.1
 [basic.lookup.unqual] paragraph 10 to make this clearer.</P>

<P>In discussing this question, the CWG noticed another problem: the
text quoted above applies to all <I>template-argument</I>s appearing in
the function declarator.  The intention of this rule, however, is that
only <I>template-argument</I>s in the <I>declarator-id</I> should
ignore the member function's class scope; <I>template-argument</I>s
used elsewhere in the function declarator should be treated like other
names.  For example:</P>

<PRE>
     template&lt;typename T&gt; struct S;
     struct A {
       typedef int T;
       void foo(S&lt;T&gt;);
     };
     template &lt;typename T&gt; struct B {
       friend void A::foo(S&lt;T&gt;);  //<SPAN STYLE="font-family:Times"><I> i.e., </I></SPAN>S&lt;A::T&gt;
     };
</PRE>

<BR><BR><HR><A NAME="225"></A><H4>225.
  
Koenig lookup and fundamental types
</H4><B>Section: </B>3.4.2&#160;
 [basic.lookup.argdep]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Derek Inglis
 &#160;&#160;&#160;

 <B>Date: </B>26 Jan 2000<BR>


<P>In discussing <A HREF="
     cwg_defects.html#197">issue 197</A>, the question
arose as to whether the handling of fundamental types in
argument-dependent lookup is actually what is desired.  This question
needs further discussion.</P>
<BR><BR><HR><A NAME="156"></A><H4>156.
  
Name lookup for conversion functions
</H4><B>Section: </B>3.4.5&#160;
 [basic.lookup.classref]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Derek Inglis
 &#160;&#160;&#160;

 <B>Date: </B>18 Aug 1999<BR>





<P>Paragraph 7 of
3.4.5
 [basic.lookup.classref]
 says,</P>

<BLOCKQUOTE>
If the <I>id-expression</I> is a <I>conversion-function-id</I>, its
<I>conversion-type-id</I> shall denote the same
type in both the context in which the
entire <I>postfix-expression</I> occurs
and in the context of the class of the object
expression (or the class pointed to by the pointer expression).
</BLOCKQUOTE>

Does this mean that the following example is ill-formed?

<PRE>
    struct A { operator int(); } a;
    void foo() {
      typedef int T;
      a.operator T(); // 1) error T is not found in the context
		      // of the class of the object expression?
    }
</PRE>

The second bullet in paragraph 1 of 
3.4.3.1
 [class.qual]
 says,

<BLOCKQUOTE>
a <I>conversion-type-id</I> of an
<I>operator-function-id</I> is looked up both
in the scope of the class and in the
context in which the entire <I>postfix-expression</I>
occurs and shall refer to the
same type in both contexts
</BLOCKQUOTE>

How about:

<PRE>
    struct A { typedef int T; operator T(); };
    struct B : A { operator T(); } b;
    void foo() {
      b.A::operator T(); // 2) error T is not found in the context
			 // of the postfix-expression?
    }
</PRE>

Is this interpretation correct?  Or was the intent for
this to be an error only if
<TT>T</TT> was found in both scopes and referred to different entities?

<P>If the intent was for these to be errors,
how do these rules apply to template
arguments?</P>

<PRE>
    template &lt;class T1&gt; struct A { operator T1(); }
    template &lt;class T2&gt; struct B : A&lt;T2&gt; {
      operator T2();
      void foo() {
	T2 a = A&lt;T2&gt;::operator T2(); // 3) error? when instantiated T2 is not
				     // found in the scope of the class
	T2 b = ((A&lt;T2&gt;*)this)-&gt;operator T2(); // 4) error when instantiated?
      }
    }
</PRE>

<P>(Note bullets 2 and 3 in paragraph 1 of
3.4.3.1
 [class.qual]
 refer to
<I>postfix-expression</I>.  It would be better to use
<I>qualified-id</I> in both cases.)</P>

<P><U>Erwin Unruh</U>:
The intent was that you look in both contexts. If you find it only once,
that's the symbol. If you find it in both, both symbols must be "the same"
in some respect. (If you don't find it, its an error).</P>

<P><U>Mike Miller</U>:
What's not clear to me in these examples is whether what is
being looked up is <TT>T</TT> or <TT>int</TT>.
Clearly the <TT>T</TT> has to be
looked up somehow, but the "name" of a conversion function
clearly involves the base (non-typedefed) type, not typedefs
that might be used in a definition or reference (cf
3
 [basic]
 paragraph 7 and
12.3
 [class.conv]
 paragraph 5).
(This is true even for types that must be written
using typedefs because of the limited syntax in
<I>conversion-type-id</I>s &#8212; e.g., the "name" of the conversion
function in the following example</P>

<PRE>
    typedef void (*pf)();
    struct S {
	operator pf();
    };
</PRE>

is <TT>S::operator void(*)()</TT>, even though you can't write its name
directly.)

<P>My guess is that this means that in each scope you look up
the type named in the reference and form the canonical
operator name; if the name used in the reference isn't found
in one or the other scope, the canonical name constructed
from the other scope is used.  These names must be identical,
and the <I>conversion-type-id</I> in the canonical operator name must
not denote different types in the two scopes (i.e., the type
might not be found in one or the other scope, but if it's found
in both, they must be the same type).</P>

<P>I think this is all very vague in the current wording.</P>
<BR><BR><HR><A NAME="682"></A><H4>682.
  
Missing description of lookup of template aliases
</H4><B>Section: </B>3.4.5&#160;
 [basic.lookup.classref]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>1 March, 2008<BR>


<P>3.4.5
 [basic.lookup.classref] does not mention template aliases as the
possible result of the lookup but should do so.</P>

<BR><BR><HR><A NAME="426"></A><H4>426.
  
Identically-named variables, one internally and one externally linked, allowed?
</H4><B>Section: </B>3.5&#160;
 [basic.link]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Adamczyk
 &#160;&#160;&#160;

 <B>Date: </B>2 July 2003<BR>


<P>An example in
3.5
 [basic.link] paragraph 6 creates two file-scope variables
with the same name,
one with internal linkage and one with external.</P>
<PRE>
  static void f();
  static int i = 0;                       //1
  void g() {
          extern void f();                // internal linkage
          int i;                          //2: i has no linkage
          {
                  extern void f();        // internal linkage
                  extern int i;           //3: external linkage
          }
  }
</PRE>
<P>Is this really what we want?
C99 has 6.2.2.7/7,
which gives undefined behavior for having an identifier appear with
internal and external linkage in the same translation unit.  C++
doesn't seem to have an equivalent.</P>

<P><B>Notes from October 2003 meeting:</B></P>

<P>We agree that this is an error.  We propose to leave the example
but change the comment to indicate that line //3 has undefined
behavior, and elsewhere add a normative rule giving such a
case undefined behavior.</P>

<P><B>Proposed resolution (October, 2005):</B></P>

<P>Change 3.5
 [basic.link] paragraph 6 as indicated:</P>

<BLOCKQUOTE>

<P>...Otherwise, if no matching entity is found, the block scope entity
receives external linkage.  <B>If, within a translation unit, the same
entity is declared with both internal and external linkage, the
behavior is undefined.</B></P>

<P>[<I>Example:</I></P>

<PRE>
    static void f();
    static int i = 0;            //<SPAN STYLE="font-family:Times"><I> 1</I></SPAN>
    void g () {
        extern void f ();        //<SPAN STYLE="font-family:Times"><I> internal linkage</I></SPAN>
        int i;                   //<SPAN STYLE="font-family:Times"><I> 2: </I><TT>i</TT><I> has no linkage</I></SPAN>
        {
            extern void f ();    //<SPAN STYLE="font-family:Times"><I> internal linkage</I></SPAN>
            extern int i;        //<SPAN STYLE="font-family:Times"><I> 3: external linkage</I></SPAN>
        }
    }
</PRE>

<P><S>There are three objects named <TT>i</TT> in this program.  The
object with internal linkage introduced by the declaration in global
scope (line <TT>//1</TT> ), the object with automatic storage duration
and no linkage introduced by the declaration on line <TT>//2</TT>, and
the object with static storage duration and external linkage
introduced by the declaration on line <TT>//3</TT>.</S> <B>Without the
declaration at line <TT>//2</TT>, the declaration at line <TT>//3</TT>
would link with the declaration at line <TT>//1</TT>.  But because the
declaration with internal linkage is hidden, <TT>//3</TT> is given
external linkage, resulting in a linkage conflict.</B> &#8212;<I>end
example</I>]</P>

</BLOCKQUOTE>

<P><B>Notes frum the April 2006 meeting:</B></P>

<P>According to 3.5
 [basic.link] paragraph 9, the two
variables with linkage in the proposed example are not &#8220;the
same entity&#8221; because they do not have the same linkage.  Some other
formulation will be needed to describe the relationship between those
two variables.</P>

<P><B>Notes from the October 2006 meeting:</B></P>

<P>The CWG decided that it would be better to make a program with this
kind of linkage mismatch ill-formed instead of having undefined
behavior.</P>

<BR><BR><HR><A NAME="527"></A><H4>527.
  
Problems with linkage of types
</H4><B>Section: </B>3.5&#160;
 [basic.link]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>28 July 2005<BR>


<P>The resolution of <A HREF="
     cwg_defects.html#389">issue 389</A> makes code
like</P>

<PRE>
    static struct {
        int i;
        int j;
    } X;
</PRE>

<P>ill-formed.  This breaks a lot of code for no apparent reason,
since the name <TT>X</TT> is not known outside the translation
unit in which it appears; there is therefore no danger of collision
and no need to mangle its name.</P>

<P>There has also been recent discussion on the email reflectors as to
whether the restrictions preventing use of types without linkage as
template arguments is needed or not, with the suggestion that a
mechanism like that used to give members of the unnamed namespace
unique names could be used for unnamed and local types.
  See also
<A HREF="
     cwg_defects.html#488">issue 488</A>, which would become moot if
types without linkage could be used as template parameters.
</P>

<P><B>Notes from the October, 2005 meeting:</B></P>

<P>The Evolution Working Group is discussing changes that would
address this issue.  CWG will defer consideration until the outcome
of the EWG discussions is clear.</P>

<P><B>Notes from the April, 2006 meeting:</B></P>

<P>The CWG agreed that the restriction in 3.5
 [basic.link]
paragraph 8 on use of a type without linkage should apply only to
variables and functions with external linkage, not to variables and
functions with internal linkage (i.e., the example should be
accepted).  This is a separate issue from the question before the EWG
and should be resolved independently.</P>

<P><B>Additional note (April, 2006):</B></P>

<P>Even the restriction of the rule to functions and objects with
external linkage may not be exactly what we want.  Consider an example
like:</P>

<PRE>
    namespace {
        struct { int i; } s;
    }
</PRE>

<P>The variable <TT>s</TT> has external linkage but can't be named
outside its translation unit, so there's again no reason to prohibit
use of a type without linkage in its declaration.</P>

<P><B>Notes from the June, 2008 meeting:</B></P>

<P>Paper N2657, adopted at the June, 2008 meeting, allows local and
unnamed types to be used as template parameters.  That resolution
is narrowly focused, however, and does not address this issue.</P>

<BR><BR><HR><A NAME="350"></A><H4>350.
  
<TT>signed char</TT> underlying representation for objects
</H4><B>Section: </B>3.9&#160;
 [basic.types]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Noah Stein
 &#160;&#160;&#160;

 <B>Date: </B>16 April 2002<BR>


<P>Sent in by David Abrahams:</P>

<P>Yes, and to add to this tangent, 3.9.1
 [basic.fundamental]
paragraph 1 states "Plain char, signed char, and unsigned char are
three distinct types."  Strangely, 3.9
 [basic.types]
paragraph 2 talks about how "... the underlying bytes making up
the object can be copied into an array of char or unsigned char.
If the content of the array of char or unsigned char is copied back
into the object, the object shall subsequently hold its original
value."  I guess there's no requirement that this copying
work properly with signed chars!</P>

<P><B>Notes from October 2002 meeting:</B></P>

<P>We should do whatever C99 does.  6.5p6 of the C99 standard says
"array of character type", and "character type" includes signed
char (6.2.5p15), and 6.5p7 says "character type".
But see also 6.2.6.1p4, which mentions (only) an array of unsigned char.</P>

<P><B>Proposed resolution (April 2003):</B></P>

<P>Change 3.8
 [basic.life] paragraph 5 bullet 3 from</P>

<UL><LI>
the pointer is used as the operand of a
<TT>static_cast</TT>
(5.2.9
 [expr.static.cast])
(except when the conversion is to
<TT>void*</TT>,
or to
<TT>void*</TT>
and subsequently to
<TT>char*</TT>,
or
<TT>unsigned</TT>
<TT>char*</TT>).
</LI>
</UL>

<P>to</P>

<UL><LI>
the pointer is used as the operand of a
<TT>static_cast</TT>
(5.2.9
 [expr.static.cast])
(except when the conversion is to
<TT>void*</TT>,
or to
<TT>void*</TT>
and subsequently to a pointer to byte-character type).
</LI>
</UL>

<P>Change 3.8
 [basic.life] paragraph 6 bullet 3 from </P>
<UL><LI>
the lvalue is used as the operand of a
<TT>static_cast</TT>
(5.2.9
 [expr.static.cast])
(except when the conversion is ultimately to
<TT>char&amp;</TT>
or
<TT>unsigned</TT>
<TT>char&amp;</TT>),
or
</LI>
</UL>
<P>to</P>
<UL><LI>
the lvalue is used as the operand of a
<TT>static_cast</TT>
(5.2.9
 [expr.static.cast])
(except when the conversion is ultimately to a reference to
byte-character type),
or
</LI>
</UL>

<P>Change the beginning of 3.9
 [basic.types] paragraph 2 from</P>
<BLOCKQUOTE>
For any object (other than a base-class subobject) of POD type
<TT>T</TT>,
whether or not the object holds a valid value of type
<TT>T</TT>,
the underlying bytes (1.7
 [intro.memory])
making up the object can be copied
into an array of
<TT>char</TT>
or
<TT>unsigned</TT>
<TT>char</TT>.
</BLOCKQUOTE>
<P>to</P>
<BLOCKQUOTE>
For any object (other than a base-class subobject) of POD type
<TT>T</TT>,
whether or not the object holds a valid value of type
<TT>T</TT>,
the underlying bytes (1.7
 [intro.memory])
making up the object can be copied
into an array of byte-character type.
</BLOCKQUOTE>

<P>Add the indicated text to 3.9.1
 [basic.fundamental] paragraph 1:</P>

<BLOCKQUOTE>
Objects declared as characters
(<TT>char</TT>)
shall be large enough to store any member of
the implementation's basic character set.
If a character from this set is stored in a character object,
the integral value of that character object
is equal to
the value of the single character literal form of that character.
It is implementation-defined whether a
<TT>char</TT>
object can hold negative values.
Characters can be explicitly declared
<TT>unsigned</TT>
or
<TT>signed</TT>.
Plain
<TT>char</TT>,
<TT>signed char</TT>,
and
<TT>unsigned char</TT>
are three distinct types<B>, called the <I>byte-character types</I></B>.
A
<TT>char</TT>,
a
<TT>signed char</TT>,
and an
<TT>unsigned char</TT>
occupy the same amount of storage and have the same alignment requirements
(3.9
 [basic.types]); that is, they have the
same object representation.
For <B>byte-</B>character types, all bits of the object representation participate in
the value representation.
For unsigned <B>byte-</B>character types, all possible bit
patterns of the value representation represent numbers.
These requirements
do not hold for other types.
In any particular implementation, a plain
<TT>char</TT>
object can take on either the same values as a
<TT>signed char</TT>
or an
<TT>unsigned char</TT>;
which one is implementation-defined.
</BLOCKQUOTE>

<P>Change 3.10
 [basic.lval] paragraph 15 last bullet from</P>
<UL><LI>
a
<TT>char</TT>
or
<TT>unsigned</TT>
<TT>char</TT>
type.
</LI>
</UL>
<P>to</P>
<UL><LI>
a byte-character type.
</LI>
</UL>

<P><B>Notes from October 2003 meeting:</B></P>

<P>It appears that in C99 signed char may have padding bits but no trap
representation, whereas in C++ signed char has no padding bits but
may have -0.  A memcpy in C++ would have to copy the array preserving
the actual representation and not just the value.</P>

<P>March 2004: The liaisons to the C committee have been asked to tell us
whether this change would introduce any unnecessary incompatibilities
with C.</P>

<P><B>Notes from October 2004 meeting:</B></P>

<P>The C99 Standard appears to be inconsistent in its
requirements.  For example, 6.2.6.1 paragraph 4 says:</P>

<BLOCKQUOTE>

The value may be copied into an object of type
<TT>unsigned&#160;char&#160;[</TT><I>n</I><TT>]</TT> (e.g., by
<TT>memcpy</TT>); the resulting set of bytes is called the
<I>object representation</I> of the value.

</BLOCKQUOTE>

<P>On the other hand, 6.2 paragraph 6 says,</P>

<BLOCKQUOTE>

If a value is copied into an object having no declared type using
<TT>memcpy</TT> or <TT>memmove</TT>, or is copied as an array of
character type, then the effective type of the modified object
for that access and for subsequent accesses that do not modify
the value is the effective type of the object from which the
value is copied, if it has one.

</BLOCKQUOTE>

<P>Mike Miller will investigate further.</P>

<BR><BR><HR><A NAME="619"></A><H4>619.
  
Completeness of array types
</H4><B>Section: </B>3.9&#160;
 [basic.types]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Clamage
 &#160;&#160;&#160;

 <B>Date: </B>16 February 2007<BR>




<P>Is the following example well-formed?</P>

<PRE>
    struct S {
        static char a[5];
    };
    char S::a[];    // Unspecified bound in definition
</PRE>

<P>3.5
 [basic.link] paragraph 10 certainly makes allowance
for declarations to differ in the presence or absence of a major array
bound.  However, 3.1
 [basic.def] paragraph 5 says that</P>

<BLOCKQUOTE>

A program is ill-formed if the definition of any object gives the
object an incomplete type (3.9
 [basic.types]).

</BLOCKQUOTE>

<P>3.9
 [basic.types] paragraph 7 says,</P>

<BLOCKQUOTE>

The declared type of an array object might be an array of unknown size
and therefore be incomplete at one point in a translation unit and
complete later on; the array types at those two points (&#8220;array
of unknown bound of <TT>T</TT>&#8221; and &#8220;array of
N <TT>T</TT>&#8221;) are different types.

</BLOCKQUOTE>

<P>This wording appears to make no allowance for the C concept of
&#8220;composite type;&#8221; instead, each declaration is said
to have its own type.  By this interpretation, the example is
ill-formed, because the type declared by the definition of
<TT>S::a</TT> is incomplete.</P>

<P>If the example is intended to be well-formed, the Standard
needs explicit wording stating that an omitted array bound in a
declaration is implicitly taken from that of a visible
declaration of that object, if any.</P>

<P><B>Notes from the April, 2007 meeting:</B></P>

<P>The CWG agreed that this usage should be permitted.</P>

<P><B>Proposed resolution (June, 2008):</B></P>

<OL><LI><P>Change 8.3.4
 [dcl.array] paragraph 1 as follows:</P></LI>

<BLOCKQUOTE>

...<S>If</S> <B>Except as noted below, if</B> the constant expression
is omitted, the type of the identifier of <TT>D</TT> is
&#8220;<I>derived-declarator-type-list</I> array of unknown bound of
<TT>T</TT>,&#8221; an incomplete object type...

</BLOCKQUOTE>

<LI><P>Change 8.3.4
 [dcl.array] paragraph 3 as follows:</P></LI>

<BLOCKQUOTE>

When several &#8220;array of&#8221; specifications are adjacent, a
multidimensional array is created; <B>only the first of</B> the
constant expressions that specify the bounds of the arrays <S>can</S>
<B>may</B> be omitted <S>only for the first member of the
sequence. [<I>Note:</I> this elision is useful for function parameters
of array types, and when the array is external and the definition,
which allocates storage, is given elsewhere. &#8212;<I>end
note</I>]</S> <B>In addition to declarations in which an incomplete
object type is allowed, an array bound may be omitted in the
declaration of a function parameter (8.3.5
 [dcl.fct]).</B>
<S>The first <I>constant-expression</I> can</S> <B>An array bound
may</B> also be omitted when the declarator is followed by an
<I>initializer</I> (8.5
 [dcl.init]). In this case the bound
is calculated from the number of initial elements (say, <TT>N</TT>)
supplied (8.5.1
 [dcl.init.aggr]), and the type of the identifier
of <TT>D</TT> is &#8220;array of <TT>N</TT> <TT>T</TT>.&#8221;
<B>Furthermore, if there is a visible declaration of the name declared
by the <I>declarator-id</I> (if any) in which the bound was specified,
an omitted array bound is taken to be the same as in that earlier
declaration.</B>

</BLOCKQUOTE>

</OL>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>The proposed resolution does not capture the result favored
by the CWG: array bound information should be accumulated across
declarations within the same scope, but a block extern declaration
in a nested scope should not inherit array bound information from
the outer declaration.  (This is consistent with the treatment of
default arguments in function declarations.)  For example:</P>

<PRE>
    int a[5];
    void f() {
        extern int a[];
        sizeof(a);
    }
</PRE>

<P>Although there was some confusion about the C99 wording dealing
with this case, it is probably well-formed in C99.  However, it
should be ill-formed in C++, because we want to avoid the
concept of &#8220;compatible types&#8221; as it exists in C.</P>

<BR><BR><HR><A NAME="636"></A><H4>636.
  
Dynamic type of objects and aliasing
</H4><B>Section: </B>3.10&#160;
 [basic.lval]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Gabriel Dos Reis
 &#160;&#160;&#160;

 <B>Date: </B>23 May 2007<BR>




<P>The aliasing rules given in 3.10
 [basic.lval] paragraph
10 rely on the concept of &#8220;dynamic type.&#8221;  The problem is
that the dynamic type of an object often cannot be determined (or
even sufficiently constrained) at the point at which an optimizer
needs to be able to determine whether aliasing might occur or not.
For example, consider the function</P>

<PRE>
    void foo(int* p, double* q) {
        *p = 42;
        *q = 3.14;
    }
</PRE>

<P>An optimizer, on the basis of the existing aliasing rules, might
decide that an <TT>int*</TT> and a <TT>double*</TT> cannot
refer to the same object and reorder the assignments.  This
reordering, however, could result in undefined behavior if the
function <TT>foo</TT> is called as follows:</P>

<PRE>
   void goo() {
      union {
         int i; 
         double d;
      } t;

      t.i = 12;

      foo(&amp;t.i, &amp;t.d);

      cout &lt;&lt; t.d &lt;&lt; endl;
   };
</PRE>

<P>Here, the reference to <TT>t.d</TT> after the call to
<TT>foo</TT> will be valid only if the assignments in
<TT>foo</TT> are executed in the order in which they were
written; otherwise, the union will contain an <TT>int</TT>
object rather than a <TT>double</TT>.</P>

<P>One possibility would be to require that if such aliasing
occurs, it be done only via member names and not via
pointers.</P>

<P><B>Notes from the July, 2007 meeting:</B></P>

<P>This is the same issue as C's <A href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_236.htm">DR236</A>.
The CWG expressed a desire to address the issue the same way C99
does.  The issue also occurs in C++ when placement new is used to
end the lifetime of one object and start the lifetime of a different
object occupying the same storage.</P>

<BR><BR><HR><A NAME="617"></A><H4>617.
  
Lvalue-to-rvalue conversions of uninitialized <TT>char</TT> objects
</H4><B>Section: </B>4.1&#160;
 [conv.lval]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alan Stokes
 &#160;&#160;&#160;

 <B>Date: </B>6 February 2007<BR>




<P>According to 4.1
 [conv.lval] paragraph 1, applying the
lvalue-to-rvalue conversion to any uninitialized object results in
undefined behavior.  However, character types are intended to allow
any data, including uninitialized objects and padding, to be copied
(hence the statements in 3.9.1
 [basic.fundamental] paragraph 1
that &#8220;For character types, all bits of the object representation
participate in the value representation&#8221; and in
3.10
 [basic.lval] paragraph 15 that <TT>char</TT> and
<TT>unsigned char</TT> types can alias any object).  The
lvalue-to-rvalue conversion should be permitted on uninitialized
objects of character type without evoking undefined behavior.</P>

<BR><BR><HR><A NAME="707"></A><H4>707.
  
Undefined behavior in integral-to-floating conversions
</H4><B>Section: </B>4.9&#160;
 [conv.fpint]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alberto Ganesh Barbati
 &#160;&#160;&#160;

 <B>Date: </B>2 Aug, 2008<BR>




<P>The current wording of 4.9
 [conv.fpint] paragraph 2
does not specify what should happen when converting an integer
value that is outside the representable range of the target floating
point type.  The C99 Standard covers this case explicitly in
6.3.1.4 paragraph 2:</P>

<BLOCKQUOTE>

When a value of integer type is converted to a real floating
type, if the value being converted can be represented exactly in
the new type, it is unchanged.  If the value being converted is
in the range of values that can be represented but cannot be
represented exactly, the result is either the nearest higher or
nearest lower representable value, chosen in an
implementation-defined manner.  If the value being converted is
outside the range of values that can be represented, the behavior
is undefined.

</BLOCKQUOTE>

<P>While the current C++ specification requires defined behavior
in all cases, the C specification allows for use of NaNs and
traps, if those are needed for efficiency.</P>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>The CWG agreed that the C approach should be adopted.</P>

<BR><BR><HR><A NAME="170"></A><H4>170.
  
Pointer-to-member conversions
</H4><B>Section: </B>4.11&#160;
 [conv.mem]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Stump
 &#160;&#160;&#160;

 <B>Date: </B>16 Sep 1999<BR>





<P>The descriptions of explicit
(5.2.9
 [expr.static.cast]
 paragraph 9) and
implicit (4.11
 [conv.mem]
 paragraph 2)
pointer-to-member conversions differ in two significant ways:</P>

<OL>
<LI>In a <TT>static_cast</TT>, a conversion in which the class in
the target pointer-to-member type is a base of the class in which
the member is declared is permitted and required to work correctly,
as long as the resulting pointer-to-member is eventually
dereferenced with an object whose dynamic type contains the
member.  That is, the class of the target pointer-to-member type
is not required to contain the member referred to by the value
being converted.  The specification of implicit pointer-to-member
conversion is silent on this question.

<P>(This situation cannot arise in an implicit pointer-to-member
conversion where the source value is something like <TT>&amp;X::f</TT>,
since you can only implicitly convert from pointer-to-base-member
to pointer-to-derived-member.  However, if the source value is
the result of an explicit "up-cast," the target type of the
conversion might still not contain the member referred to by the
source value.)</P></LI>

<LI>The target type in a <TT>static_cast</TT> is allowed to be
more cv-qualified than the source type; in an implicit conversion,
however, the cv-qualifications of the two types are required to
be identical.</LI>
</OL>

The first difference seems like an oversight.  It is not clear
whether the latter difference is intentional or not.
<BR><BR><HR><A NAME="536"></A><H4>536.
  
Problems in the description of <I>id-expression</I>s
</H4><B>Section: </B>5.1&#160;
 [expr.prim]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>13 October 2005<BR>


<P>There are at least a couple of problems in the description of
the various <I>id-expression</I>s in 5.1
 [expr.prim]:</P>

<OL><LI><P>Paragraph 4 embodies an incorrect assumption about the
syntax of <I>qualified-id</I>s:</P>

<BLOCKQUOTE>

The operator <TT>::</TT> followed by an <I>identifier</I>, a
<I>qualified-id</I>, or an <I>operator-function-id</I> is a
<I>primary-expression</I>.

</BLOCKQUOTE>

<P>The problem here is that the <TT>::</TT> is actually part of the
syntax of <I>qualified-id</I>; consequently, &#8220;<TT>::</TT> followed by...
a <I>qualified-id</I>&#8221; could be something like
&#8220;<TT>:: ::i</TT>,&#8221; which is ill-formed.  Presumably
this should say something like, &#8220;A <I>qualified-id</I> with
no <I>nested-name-specifier</I> is a <I>primary-expression</I>.&#8221;</P>
</LI>

<LI><P>More importantly, some kinds of <I>id-expression</I>s are not
described by 5.1
 [expr.prim].  The structure of this
section is that the result, type, and lvalue-ness are specified for
each of the cases it covers:</P>

<UL>
<LI><P>paragraph 4 deals with <I>qualified-id</I>s that have no
<I>nested-name-specifier</I></P></LI>

<LI><P>paragraph 7 deals with bare <I>identifier</I>s and with
<I>qualified-id</I>s containing a <I>nested-name-specifier</I>
that names a class</P></LI>

<LI><P>paragraph 8 deals with <I>qualified-id</I>s containing a
<I>nested-name-specifier</I> that names a namespace</P></LI>

</UL>

<P>This treatment leaves unspecified all the non-<I>identifier</I>
<I>unqualified-id</I>s (<I>operator-function-id</I>,
<I>conversion-function-id</I>, and <I>template-id</I>), as well as
(perhaps) &#8220;<TT>::</TT> <I>template-id</I>&#8221; (it's not clear
whether the &#8220;<TT>::</TT> followed by a <I>qualified-id</I>&#8221; case
is supposed to apply to <I>template-id</I>s or not).  Note also that the
proposed resolution of <A HREF="
     cwg_defects.html#301">issue 301</A> slightly
exacerbates this problem by removing the form
of <I>operator-function-id</I> that contains
a <I>tmeplate-argument-list</I>; as a result, references like
&#8220;<TT>::operator+&lt;X&gt;</TT>&#8221; are no longer covered in
5.1
 [expr.prim].</P>
</LI>

</OL>

<BR><BR><HR><A NAME="573"></A><H4>573.
  
Conversions between function pointers and <TT>void*</TT>
</H4><B>Section: </B>5.2.10&#160;
 [expr.reinterpret.cast]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Adamczyk
 &#160;&#160;&#160;

 <B>Date: </B>13 April 2006<BR>


<P>The resolution to <A HREF="
     cwg_defects.html#195">issue 195</A> makes
&#8220;converting a pointer to a function into a pointer to an object
type or vice versa&#8221; conditionally-supported behavior.  In doing
so, however, it overlooked the fact that <TT>void</TT> is not an
&#8220;object type&#8221; (3.9
 [basic.types] paragraph 9).
The wording should be amended to allow conversion to and
from <TT>void*</TT> types.</P>

<P><B>Proposed resolution (June, 2008):</B></P>

<OL><LI><P>Change 3.9.2
 [basic.compound] paragraph 4 as follows:</P></LI>

<BLOCKQUOTE>

<S>Objects of cv-qualified (3.9.3
 [basic.type.qualifier]) or
cv-unqualified type <TT>void*</TT> (pointer to void)</S> <B>A pointer
to cv-qualified or cv-unqualified <TT>void</TT></B> can be used to
point to objects of unknown type. A <TT>void*</TT> shall be able to
hold any object pointer <B>and is thus considered to be an object
pointer type, although it is not a pointer to object type (because
<TT>void</TT> is not an object type)</B>. <S>A cv-qualified or
cv-unqualified (3.9.3
 [basic.type.qualifier])</S> <B>An object of type
<I>cv</I></B> <TT>void*</TT> shall have the same representation and
alignment requirements as <S>a cv-qualified or cv-unqualified</S>
<B><I>cv</I></B> <TT>char*</TT>.

</BLOCKQUOTE>

<LI><P>Change 4.10
 [conv.ptr] paragraph 1 as follows:</P></LI>

<BLOCKQUOTE>

...A null pointer constant can be converted to a pointer type; the
result is the null pointer value of that type and is distinguishable
from every other value of <S>pointer to object or pointer to function</S>
<B>object pointer or function pointer</B> type...

</BLOCKQUOTE>

<LI><P>Change 5.2.10
 [expr.reinterpret.cast] paragraph 7 as follows:</P></LI>

<BLOCKQUOTE>

<S>A pointer to an object</S> <B>An object pointer</B> can be
explicitly converted to <S>a pointer to an object</S> <B>an object
pointer</B> of different type. Except that converting an rvalue of
type &#8220;pointer to <TT>T1</TT>&#8221; to the type &#8220;pointer
to <TT>T2</TT>&#8221; (where <TT>T1</TT> and <TT>T2</TT> are object
types <B>or <TT>void</TT></B> and where the alignment requirements of
<TT>T2</TT> are no stricter than those of <TT>T1</TT>) and back to its
original type yields the original pointer value, the result of such a
pointer conversion is unspecified.

</BLOCKQUOTE>

<LI><P>Change 5.2.10
 [expr.reinterpret.cast] paragraph 8 as follows:</P></LI>

<BLOCKQUOTE>

Converting a <S>pointer to a function into a pointer to an object
type</S> <B>a function pointer to an object pointer</B> or vice versa
is conditionally-supported...

</BLOCKQUOTE>

</OL>

<P><I>[Drafting note: 14.1
 [temp.param] paragraph 4 was not
changed and thus continues to allow only pointers to objects, not
object pointers, as non-type template parameters.]</I></P>

<BR><BR><HR><A NAME="232"></A><H4>232.
  
Is indirection through a null pointer undefined behavior?
</H4><B>Section: </B>5.3.1&#160;
 [expr.unary.op]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>5 Jun 2000<BR>




<P>At least a couple of places in the IS state that indirection
through a null pointer produces undefined behavior: 1.9
 [intro.execution] paragraph 4 gives "dereferencing the null pointer" as an
example of undefined behavior, and 8.3.2
 [dcl.ref]
paragraph 4 (in a note) uses this supposedly undefined behavior as
justification for the nonexistence of "null references."</P>

<P>However, 5.3.1
 [expr.unary.op] paragraph 1, which describes
the unary "*" operator, does <I>not</I> say that the behavior is
undefined if the operand is a null pointer, as one might expect.
Furthermore, at least one passage gives dereferencing a null pointer
well-defined behavior: 5.2.8
 [expr.typeid] paragraph 2
says</P>

<BLOCKQUOTE>
If the lvalue expression is obtained by applying the unary * operator
to a pointer and the pointer is a null pointer value (4.10
 [conv.ptr]), the <TT>typeid</TT> expression throws the
<TT>bad_typeid</TT> exception (18.6.4
 [bad.typeid]).
</BLOCKQUOTE>

<P>This is inconsistent and should be cleaned up.</P>

<P><U>Bill Gibbons</U>:</P>

<P>At one point we agreed that dereferencing a null pointer was
<I>not</I> undefined; only using the resulting value had undefined
behavior.</P>

<P>For example:</P>

<PRE>
    char *p = 0;
    char *q = &amp;*p;
</PRE>

<P>Similarly, dereferencing a pointer to the end of an array should be
allowed as long as the value is not used:</P>

<PRE>
    char a[10];
    char *b = &amp;a[10];   // equivalent to "char *b = &amp;*(a+10);"
</PRE>

<P>Both cases come up often enough in real code that they should be
allowed.</P>

<P><U>Mike Miller</U>:</P>

<P>I can see the value in this, but it doesn't seem to be well
reflected in the wording of the Standard.  For instance, presumably
<TT>*p</TT> above would have to be an lvalue in order to be the
operand of "<TT>&amp;</TT>", but the definition of "lvalue" in
3.10
 [basic.lval] paragraph 2 says that "an lvalue refers to
an object."  What's the object in <TT>*p</TT>?  If we were to allow
this, we would need to augment the definition to include the result of
dereferencing null and one-past-the-end-of-array.</P>

<P><U>Tom Plum</U>:</P>

<P>Just to add one more recollection of the intent: I was <I>very</I>
happy when (I thought) we decided that it was only the attempt to
actually fetch a value that creates undefined behavior.  The words
which (I thought) were intended to clarify that are the first three
sentences of the lvalue-to-rvalue conversion, 4.1
 [conv.lval]:</P>

<BLOCKQUOTE>

An lvalue (3.10
 [basic.lval]) of a non-function, non-array
type <TT>T</TT> can be converted to an rvalue.  If <TT>T</TT> is an
incomplete type, a program that necessitates this conversion is
ill-formed.  If the object to which the lvalue refers is not an object
of type <TT>T</TT> and is not an object of a type derived from
<TT>T</TT>, or if the object is uninitialized, a program that
necessitates this conversion has undefined behavior.

</BLOCKQUOTE>

<P>In other words, it is only the act of "fetching", of
lvalue-to-rvalue conversion, that triggers the ill-formed or undefined
behavior.  Simply forming the lvalue expression, and then for example
taking its address, does not trigger either of those errors.  I
described this approach to WG14 and it may have been incorporated into
C 1999.</P>

<P><U>Mike Miller</U>:</P>

<P>If we admit the possibility of null lvalues, as Tom is suggesting
here, that significantly undercuts the rationale for prohibiting "null
references" -- what is a reference, after all, but a named lvalue?  If
it's okay to create a null lvalue, as long as I don't invoke the
lvalue-to-rvalue conversion on it, why shouldn't I be able to capture
that null lvalue as a reference, with the same restrictions on its
use?</P>

<P>I am not arguing in favor of null references.  I don't want them in
the language.  What I am saying is that we need to think carefully
about adopting the permissive approach of saying that it's all right
to create null lvalues, as long as you don't use them in certain ways.
If we do that, it will be very natural for people to question why they
can't pass such an lvalue to a function, as long as the function
doesn't do anything that is not permitted on a null lvalue.
</P>

<P>If we want to allow <TT>&amp;*(p=0)</TT>, maybe we should change
the definition of "<TT>&amp;</TT>" to handle dereferenced null
specially, just as <TT>typeid</TT> has special handling, rather than
changing the definition of lvalue to include dereferenced nulls, and
similarly for the array_end+1 case.  It's not as general, but I think
it might cause us fewer problems in the long run.
</P>

<P><B>Notes from the October 2003 meeting:</B></P>

<P>See also <A HREF="
     cwg_closed.html#315">issue 315</A>, which deals with
the call of a static member function through a null pointer.</P>

<P>We agreed that the approach in the standard seems okay:
<TT>p = 0; *p;</TT> is not inherently an error.  An
lvalue-to-rvalue conversion would give it undefined behavior.</P>

<P><B>Proposed resolution (October, 2004):</B></P>

<P>(Note: the resolution of <A HREF="
     cwg_active.html#453">issue 453</A>
also resolves part of this issue.)</P>

<OL>

<LI><P>Add the indicated words to 3.10
 [basic.lval]
paragraph 2:</P>

<BLOCKQUOTE>

An lvalue refers to an object or function <B>or is an empty lvalue
(5.3.1
 [expr.unary.op])</B>.

</BLOCKQUOTE>

</LI>

<LI><P>Add the indicated words to 5.3.1
 [expr.unary.op]
paragraph 1:</P>

<BLOCKQUOTE>

The unary <TT>*</TT> operator performs <I>indirection</I>: the
expression to which it is applied shall be a pointer to an object
type, or a pointer to a function type and the result is an lvalue
referring to the object or function to which the expression
points<B>, if any. If the pointer is a null pointer value
(4.10
 [conv.ptr]) or points one past the last element
of an array object (5.7
 [expr.add]), the result is an
<I>empty lvalue</I> and does not refer to any object or function.
An empty lvalue is not modifiable</B>.  If the type of the
expression is &#8220;pointer to <TT>T</TT>,&#8221; the type of
the result is &#8220;<TT>T</TT>.&#8221; [<I>Note:</I> a pointer to an
incomplete type (other than cv void) can be dereferenced. The
lvalue thus obtained can be used in limited ways (to initialize a
reference, for example); this lvalue must not be converted to an
rvalue, see 4.1
 [conv.lval].&#8212;<I>end note</I>]

</BLOCKQUOTE>

</LI>

<LI><P>Add the indicated words to 4.1
 [conv.lval]
paragraph 1:</P>

<BLOCKQUOTE>

If the object to which the lvalue refers is not an object of type
<TT>T</TT> and is not an object of a type derived from
<TT>T</TT>, or if the object is uninitialized, <B>or if the
lvalue is an empty lvalue (5.3.1
 [expr.unary.op]),</B> a
program that necessitates this conversion has undefined behavior.

</BLOCKQUOTE>

</LI>

<LI><P>Change 1.9
 [intro.execution] as indicated:</P>

<BLOCKQUOTE>

Certain other operations are described in this International
Standard as undefined (for example, the effect of <S>dereferencing
the null pointer</S> <B>division by zero</B>).

</BLOCKQUOTE>

</LI>

</OL>

<P><B>Note (March, 2005):</B></P> 

<P>The 10/2004 resolution interacts with the resolution of <A HREF="
     cwg_defects.html#73">issue 73</A>.  We added wording to 3.9.2
 [basic.compound] paragraph 3 to the effect that a pointer containing
the address one past the end of an array is considered to &#8220;point
to&#8221; another object of the same type that might be located there.
The 10/2004 resolution now says that it would be undefined behavior to
use such a pointer to fetch the value of that object.  There is at
least the appearance of conflict here; it may be all right, but it at
needs to be discussed further.</P>

<P><B>Notes from the April, 2005 meeting:</B>
</P>

<P>The CWG agreed that there is no contradiction between this
direction and the resolution of <A HREF="
     cwg_defects.html#73">issue 73</A>.
However, &#8220;not modifiable&#8221; is a compile-time concept, while
in fact this deals with runtime values and thus should produce
undefined behavior instead.  Also, there are other contexts in which
lvalues can occur, such as the left operand of <TT>.</TT>
or <TT>.*</TT>, which should also be restricted.  Additional drafting
is required.</P>

<BR><BR><HR><A NAME="672"></A><H4>672.
  
Sequencing of initialization in <I>new-expression</I>s
</H4><B>Section: </B>5.3.4&#160;
 [expr.new]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Clark Nelson
 &#160;&#160;&#160;

 <B>Date: </B>11 January, 2008<BR>




<P>Consider the following code, which uses double-checked locking
(DCL):</P>

<PRE>
    Widget* Widget::Instance() {
      if (pInstance == 0) {           //<SPAN STYLE="font-family:Times"><I> 1: first check</I></SPAN>
        lock&lt;mutex&gt; hold(mutW);       //<SPAN STYLE="font-family:Times"><I> 2: acquire lock</I></SPAN>
        if (pInstance == 0) {         //<SPAN STYLE="font-family:Times"><I> 3: second check</I></SPAN>
          pInstance = new Widget();   //<SPAN STYLE="font-family:Times"><I> 4: create and assign</I></SPAN>
        }
      }                               //<SPAN STYLE="font-family:Times"><I> 5: release lock</I></SPAN>
    }
</PRE>

<P>We want this to be fully correct when <TT>pInstance</TT> is an
atomic pointer to <TT>Widget</TT>. To get that result, we have to
disallow any assignment to <TT>pInstance</TT> until after the new
object is fully constructed. In other words, we want this to be an
invalid transformation of line 4:</P>

<PRE>
    pInstance = operator new(sizeof(Widget));
    new (pInstance) Widget;
</PRE>

<P>I don't think it would be surprising if this were disallowed. For
example, if the constructor were to throw an exception, I think many
people would expect the variable not to be modified. I think the
question is whether it's sufficiently clearly disallowed.</P>

<P>This could be clarified by stating (somewhere appropriate &#8212;
probably either in 5.3.4
 [expr.new] paragraph 16 or
paragraph 22) that the initialization of the allocated object is
sequenced before the value computation of the <I>new-expression</I>.
Then by 5.17
 [expr.ass] paragraph 1 (&#8220;In all cases,
the assignment is sequenced after the value computation of the right
and left operands, and before the value computation of the assignment
expression.&#8221;), the initialization would have to be sequenced
before the assignment.</P>

<P>This is probably not a problem for <TT>atomic&lt;Widget*&gt;</TT>
because its <TT>operator=</TT> is a function, and function calls
provide the necessary guarantees.  But for the plain pointer
assignment case, there's still a question about whether the sequencing
of side effects is constrained as tightly as it should be. In fact,
you don't even have to throw an exception from the constructor for
there to be a question.</P>

<PRE>
    struct X {
        static X* p;
        X();
    };

    X* X::p = new X;
</PRE>

<P>When the constructor for <TT>X</TT> is invoked by this
<I>new-expression</I>, would it be valid for <TT>X::p</TT> to be
non-null? If the answer is supposed to be &#8220;no,&#8221; then I
think the Standard should express that intent more clearly.</P>

<P><B>Proposed resolution (March, 2008):</B></P>

<P>Change 5.3.4
 [expr.new] paragraph 22 as indicated:</P>

<BLOCKQUOTE>

<S>Whether</S> <B>Initialization of the allocated object is sequenced
before the value computation of the <I>new-expression</I>.  It is
unspecified whether</B> the allocation function is called before
evaluating the constructor arguments or after evaluating the
constructor arguments but before entering the constructor<S> is
unspecified</S>. It is also unspecified whether the arguments to a
constructor are evaluated if the allocation function returns the null
pointer or exits using an exception.

</BLOCKQUOTE>

<P><I>[Drafting note: The editor may wish to move paragraph 22 up to
immediately follow paragraph 16 or 17.  The paragraphs numbered 18-21
deal with the case where deallocation is done because initialization
terminates with an exception, whereas paragraph 22 applies more to the
initialization itself, described in paragraph 16.]</I></P>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>The proposed wording does not (but should) allow the call to
the allocation function to occur in the middle of evaluating
arguments for the constructor call.</P>

<BR><BR><HR><A NAME="587"></A><H4>587.
  
Lvalue operands of a conditional expression differing only in cv-qualification
</H4><B>Section: </B>5.16&#160;
 [expr.cond]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Howard Hinnant
 &#160;&#160;&#160;

 <B>Date: </B>20 June 2006<BR>




<P>Consider the following example:</P>

<PRE>
    template &lt;typename T&gt;
    const T* f(bool b) {
        static T t1 = T();
        static const T t2 = T();
        return &amp;(b ? t1 : t2);  // error?
    }
</PRE>

<P>According to 5.16
 [expr.cond], this function is
well-formed if <TT>T</TT> is a class type and ill-formed
otherwise.  If the second and third operands of a conditional
expression are lvalues of the same class type except for
cv-qualification, the result of the conditional expression is
an lvalue; if they are lvalues of the same non-class type
except for cv-qualification, the result is an rvalue.</P>

<P>This difference seems gratuitous and should be removed.</P>

<BR><BR><HR><A NAME="407"></A><H4>407.
  
Named class with associated typedef: two names or one?
</H4><B>Section: </B>7.1.3&#160;
 [dcl.typedef]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Clark Nelson
 &#160;&#160;&#160;

 <B>Date: </B>31 March 2003<BR>


<P>Here's an example:</P>
<PRE>
  typedef struct S { ... } S;
  void fs(S *x) { ... }
</PRE>
<P>The big question is, to what declaration does the reference to identifier S
actually refer? Is it the S that's declared as a typedef name, or the S
that's declared as a class name (or in C terms, as a struct tag)? (In either
case, there's clearly only one type to which it could refer, since a typedef
declaration does not introduce a new type. But the debugger apparently cares
about more than just the identity of the type.)</P>

<P>Here's a classical, closely related example:</P>
<PRE>
  struct stat { ... };
  int stat();
  ... stat( ... ) ...
</PRE>
<P>Does the identifier stat refer to the class or the function? Obviously, in
C, you can't refer to the struct tag without using the struct keyword,
because it is in a different name space, so the reference must be to the
function. In C++, the reference is also to the function, but for a
completely different reason.</P>

<P>Now in C, typedef names and function names are in the same name space, so
the natural extrapolation would be that, in the first example, S refers to
the typedef declaration, as it would in C. But C++ is not C. For the
purposes of this discussion, there are two important differences between C
and C++</P>

<P>The first difference is that, in C++, typedef names and class names are not
in separate name spaces. On the other hand, according to section
3.3.10
 [basic.scope.hiding] (Name hiding), paragraph 2:</P>
<BLOCKQUOTE>
A class name (9.1) or enumeration name (7.2) can be hidden by <B>the name of
an object, function, or enumerator</B> declared in the same scope. If a class
or enumeration name and an object, function, or enumerator are declared in
the same scope (in any order) with the same name, the class or enumeration
name is hidden wherever the object, function, or enumerator name is
visible.
</BLOCKQUOTE>

<P>Please consider carefully the phrase I have highlighted, and the fact that a
typedef name is not the name of an object, function or enumerator. As a
result, this example:</P>
<PRE>
  struct stat { ... };
  typedef int stat;
</PRE>
<P>Which would be perfectly legal in C, is disallowed in C++, both implicitly
(see the above quote) and explicitly (see section
7.1.3
 [dcl.typedef] (The typedef
specifier), paragraph 3):</P>
<BLOCKQUOTE>
In a given scope, a typedef specifier shall not be used to redefine the
name of any type declared in that scope to refer to a different type.
Similarly, in a given scope, a class or enumeration shall not be declared
with the same name as a typedef-name that is declared in that scope and
refers to a type other than the class or enumeration itself.
</BLOCKQUOTE>

<P>From which we can conclude that in C++ typedef names do not hide class names
declared in the same scope. If they did, the above example would be legal.</P>

<P>The second difference is that, in C++, a typedef name that refers to a class
is a class-name; see 7.1.3
 [dcl.typedef] paragraph 4:</P>
<BLOCKQUOTE>
A typedef-name that names a class is a class-name(9.1). If a typedef-name
is used following the class-key in an elaborated-type-specifier (7.1.5.3) or
in the class-head of a class declaration (9), or is used as the identifier
in the declarator for a constructor or destructor declaration (12.1, 12.4),
the program is ill-formed.
</BLOCKQUOTE>

<P>This implies, for instance, that a typedef-name referring to a class can be
used in a nested-name-specifier (i.e. before :: in a qualified name) or
following ~ to refer to a destructor. Note that using a typedef-name as a
class-name in an elaborated-type-specifier is not allowed. For example:</P>
<PRE>
  struct X { };
  typedef struct X X2;
  X x; // legal
  X2 x2; // legal
  struct X sx; // legal
  struct X2 sx2; // illegal
</PRE>

<P>The final relevant piece of the standard is
7.1.3
 [dcl.typedef] paragraph 2:</P>
<BLOCKQUOTE>
In a given scope, a typedef specifier can be used to redefine the name of
any type declared in that scope to refer to the type to which it already
refers.
</BLOCKQUOTE>

<P>This of course is what allows the original example, to which let us now
return:</P>
<PRE>
  typedef struct S { ... } S;
  void fs(S *x) { ... }
</PRE>
<P>The question, again is, to which declaration of S does the reference
actually refer? In C, it would clearly be to the second, since the first
would be accessible only by using the struct keyword. In C++, if typedef
names hid class names declared in the same scope, the answer would be the
same. But we've already seen that typedef names do not hide class names
declared in the same scope.</P>

<P>So to which declaration does the reference to S refer? The answer is that it
doesn't matter. The second declaration of S, which appears to be a
declaration of a typedef name, is actually a declaration of a class name
(7.1.3
 [dcl.typedef] paragraph 4), and as such is simply a
redeclaration. Consider the following example:</P>
<PRE>
  typedef int I, I;
  extern int x, x;
  void f(), f();
</PRE>
<P>To which declaration would a reference to I, x or f refer? It doesn't
matter, because the second declaration of each is really just a
redeclaration of the thing declared in the first declaration. So to save
time, effort and complexity, the second declaration of each doesn't add any
entry to the compiler's symbol table.</P>

<P><B>Note (March, 2005):</B></P>



<P><U>Matt Austern</U>: Is this legal?</P>

<PRE>
    struct A { };
    typedef struct A A;
    struct A* p;
</PRE>

<P>Am I right in reading the standard [to say that this is
ill-formed]?  On the one hand it's a nice uniform rule.  On the other
hand, it seems likely to confuse users.  Most people are probably used
to thinking that 'typedef struct A A' is a null operation, and, if
this code really is illegal, it would seem to be a gratuitous C/C++
incompatibility.</P>

<P><U>Mike Miller</U>: I think you're right.  7.1.3
 [dcl.typedef] paragraph 1:</P>

<BLOCKQUOTE>

A name declared with the <TT>typedef</TT> specifier becomes a
<I>typedef-name</I>.

</BLOCKQUOTE>

<P>7.1.3
 [dcl.typedef] paragraph 2:</P>

<BLOCKQUOTE>

In a given non-class scope, a <TT>typedef</TT> specifier can be used
to redefine the name of any type declared in that scope
to refer to the type to which it already refers.

</BLOCKQUOTE>

<P>After the <TT>typedef</TT> declaration in the example, the name
<TT>X</TT> has been &#8220;redefined&#8221; &#8212; it is no longer
just a <I>class-name</I>, it has been &#8220;redefined&#8221; to be a
<I>typedef-name</I> (that, by virtue of the fact that it refers to a
class type, is also a <I>class-name</I>).</P>

<P><U>John Spicer</U>: In C, and originally in C++, an
<I>elaborated-type-specifier</I> did not consider typedef names, so
&#8220;<TT>struct X* x</TT>&#8221; would find the class and not the
typedef.</P>

<P>When C++ was changed to make typedefs visible to
<I>elaborated-type-specifier</I> lookups, I believe this issue was
overlooked and inadvertantly made ill-formed.
</P>

<P>I suspect we need add text saying that if a given scope contains
both a class/enum and a typedef, that an elaborated type specifier
lookup finds the class/enum.
</P>

<P><U>Mike Miller</U>: I'm a little uncomfortable with this approach.
The model we have for declaring a typedef in the same scope as a
class/enum is redefinition, not hiding (like the &#8220;<TT>struct
stat</TT>&#8221; hack).  This approach seems to assume that the
typedef hides the class/enum, which can then be found by an
<I>elaborated-type-specifier</I>, just as if it were hidden by a
variable, function, or enumerator.
</P>

<P>Also, this approach reduces but doesn't eliminate the
incompatibility with C.  For example:
</P>

<PRE>
    struct S { };
    {
        typedef struct S S;
        struct S* p;        // still ill-formed
    }
</PRE>

<P>My preference would be for something following the basic principle
that declaring a <I>typedef-name</I> <TT>T</TT> in a scope where
<TT>T</TT> already names the type designated by the typedef should
have no effect on whether an <I>elaborated-type-specifier</I> in that
or a nested scope is well-formed or not.  Another way of saying that
is that a <I>typedef-name</I> that designates a same-named class or
enumeration in the same or a containing scope is transparent with
respect to <I>elaborated-type-specifier</I>s.</P>

<P><U>John Spicer</U>: This strikes me as being a rather complicated
solution. When we made the change to make typedefs visible to
<I>elaborated-type-specifier</I>s we did so knowing it would make some
C cases ill-formed, so this does not bother me.  We've lived with the
C incompatibility for many years now, so I don't personally feel a
need to undo it.  I also don't like the fact that you have to
essentially do the old-style <I>elaborated-type-specifier</I> lookup
to check the result of the lookup that found the typedef.
</P>

<P>I continue to prefer the direction I described earlier where if a
given scope contains both a class/enum and a typedef, that an
<I>elaborated-type-specifier</I> lookup finds the class/enum.
</P>

<P><B>Notes from the April, 2005 meeting:</B></P>

<P>The CWG agreed with John Spicer's approach, i.e., permitting
a <I>typedef-name</I> to be used in an
<I>elaborated-type-specifier</I> only if it is declared in the same
scope as the class or enumeration it names.</P>

<BR><BR><HR><A NAME="625"></A><H4>625.
  
Use of <TT>auto</TT> as a <I>template-argument</I>
</H4><B>Section: </B>7.1.6.4&#160;
 [dcl.spec.auto]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>9 March 2007<BR>


<P>The <TT>auto</TT> specifier can be used only in certain contexts,
as specified in 7.1.6.4
 [dcl.spec.auto] paragraphs 2-3:</P>

<BLOCKQUOTE>

<P>Otherwise (<TT>auto</TT> appearing with no type specifiers other than
<I>cv-qualifier</I>s), the <TT>auto</TT> <I>type-specifier</I>
signifies that the type of an object being declared shall be deduced
from its initializer. The name of the object being declared shall not
appear in the initializer expression.</P>

<P>This use of <TT>auto</TT> is allowed when declaring objects in a
block (6.3
 [stmt.block]), in namespace scope (3.3.5
 [basic.scope.namespace]), and in a <I>for-init-statement</I> (6.5.3
 [stmt.for]).  The <I>decl-specifier-seq</I> shall be followed by
one or more <I>init-declarator</I>s, each of which shall have a
non-empty <I>initializer</I> of either of the following forms:</P>

<UL>
<TT>=</TT> <I>assignment-expression</I><BR>
<TT>(</TT> <I>assignment-expression</I> <TT>)</TT>
</UL>

</BLOCKQUOTE>

<P>It was intended that <TT>auto</TT> could be used only at the
top level of a declaration, but it is not clear whether this wording
is sufficient to forbid usage like the following:</P>

<PRE>
    template &lt;class T&gt; struct A {};
    template &lt;class T&gt; void f(A&lt;T&gt; x) {}

    void g()
    {
        f(A&lt;short&gt;());

        A&lt;auto&gt; x = A&lt;short&gt;();
    }
</PRE>

<P><B>Notes from the February, 2008 meeting:</B></P>

<P>It was agreed that the example should be ill-formed.</P>

<BR><BR><HR><A NAME="138"></A><H4>138.
  
Friend declaration name lookup
</H4><B>Section: </B>7.3.1.2&#160;
 [namespace.memdef]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Martin von Loewis
 &#160;&#160;&#160;

 <B>Date: </B>14 Jul 1999<BR>





<P>7.3.1.2
 [namespace.memdef]
 paragraph 3 says,</P>

<BLOCKQUOTE>
If a <TT>friend</TT> declaration in a non-local class first declares a
class or function the friend class or function is a member of the
innermost enclosing namespace...  When looking for a prior declaration
of a class or a function declared as a <TT>friend</TT>, scopes outside
the innermost enclosing namespace scope are not considered.
</BLOCKQUOTE>

It is not clear from this passage how to determine whether an entity
is "first declared" in a <TT>friend</TT> declaration.  One question is
whether a <I>using-declaration</I> influences this determination.
For instance:

<PRE>
    void foo();
    namespace A{
      using ::foo;
      class X{
	friend void foo();
      };
    }
</PRE>

Is the <TT>friend</TT> declaration a reference to <TT>::foo</TT> or
a different <TT>foo</TT>?

<P>Part of the question involves determining the meaning of
the word "synonym" in
7.3.3
 [namespace.udecl]
 paragraph 1:</P>

<BLOCKQUOTE>
A <I>using-declaration</I> introduces a name into the declarative
region in which the <I>using-declaration</I> appears.  That name
is a synonym for the name of some entity declared elsewhere.
</BLOCKQUOTE>

Is "<TT>using ::foo;</TT>" the declaration of a function or not?

<P>More generally, the question is how to describe the lookup of the
name in a <TT>friend</TT> declaration.</P>

<P><U>John Spicer</U>:
When a declaration specifies an unqualified name, that
name is declared, not looked up.  There is a mechanism in which that
declaration is linked to a prior declaration, but that mechanism is
not, in my opinion, via normal name lookup.  So, the friend always
declares a member of the nearest namespace scope regardless of how
that name may or may not already be declared there.</P>

<P><U>Mike Miller</U>:
3.4.1
 [basic.lookup.unqual]
 paragraph 7 says:</P>

<BLOCKQUOTE>
A name used in the definition of a class <TT>X</TT> outside of a
member function body or nested class definition shall be declared in
one of the following ways:...  [<I>Note:</I> when looking for a
prior declaration of a class or function introduced by a <TT>friend</TT>
declaration, scopes outside of the innermost enclosing namespace scope
are not considered.]
</BLOCKQUOTE>

The presence of this note certainly implies that this paragraph
describes the lookup of names in <TT>friend</TT> declarations.

<P><U>John Spicer</U>:
It most certainly does not.  If that section described the friend
lookup it would yield the incorrect results for the friend declarations
of <TT>f</TT> and <TT>g</TT> below.
I don't know why that note is there, but it can't
be taken to mean that that is how the friend lookup is done.</P>

<PRE>
    void f(){}
    void g(){}
    class B {
        void g();
    };
    class A : public B {
        void f();
        friend void f(); // ::f not A::f
        friend void g(); // ::g not B::g
    };
</PRE>

<P><U>Mike Miller</U>:
If so, the lookups for friend functions and classes behave differently.
Consider the example in
3.4.4
 [basic.lookup.elab]
 paragraph 3:</P>

<PRE>
    struct Base {
        struct Data;         // <I>OK: declares nested</I> Data
        friend class Data;   // <I>OK: nested</I> Data <I>is a friend</I>
    };
</PRE>

<P>If the <TT>friend</TT> declaration is <I>not</I> a reference to
<TT>::foo</TT>, there is a related but separate question: does the
<TT>friend</TT> declaration introduce a conflicting (albeit "invisible")
declaration into namespace <TT>A</TT>, or is it simply a reference
to an as-yet undeclared (and, in this instance, undeclarable)
<TT>A::foo</TT>?  Another part of the example in
3.4.4
 [basic.lookup.elab]
 paragraph 3 is
related:</P>

<PRE>
    struct Data {
        friend struct Glob;  // <I>OK: Refers to (as yet) undeclared</I> Glob
                             // <I>at global scope.</I>
    };
</PRE>

<P><U>John Spicer</U>:
You can't refer to something that has not yet been declared.  The friend
is a declaration of <TT>Glob</TT>,
it just happens to declare it in a such a way that
its name cannot be used until it is redeclared.</P>

<P>(A somewhat similar question has been raised in connection with
<A HREF="
     cwg_active.html#36">issue 36</A>.  Consider:</P>

<PRE>
    namespace N {
        struct S { };
    }
    using N::S;
    struct S;          // legal?
</PRE>

<P>According to 9.1
 [class.name] paragraph 2,</P>

<BLOCKQUOTE>

A declaration consisting solely of <I>class-key identifier ;</I>
is either a redeclaration of the name in the current scope or a
forward declaration of the identifier as a class name.

</BLOCKQUOTE>

<P>Should the elaborated type declaration in this example be
considered a redeclaration of <TT>N::S</TT> or an invalid
forward declaration of a different class?)</P>

<P>(See also issues
<A HREF="
     cwg_closed.html#95">95</A>,
<A HREF="
     cwg_defects.html#136">136</A>,
<A HREF="
     cwg_defects.html#139">139</A>,
<A HREF="
     cwg_defects.html#143">143</A>,
<A HREF="
     cwg_closed.html#165">165</A>, and
<A HREF="
     cwg_defects.html#166">166</A>, as well as paper J16/00-0006 = WG21
N1229.)</P>



<BR><BR><HR><A NAME="341"></A><H4>341.
  
<TT>extern "C"</TT> namespace member function versus global variable
</H4><B>Section: </B>7.5&#160;
 [dcl.link]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Adamczyk
 &#160;&#160;&#160;

 <B>Date: </B>1 Mar 2002<BR>




<P>Here's an interesting case:
<PRE>
  int f;
  namespace N {
    extern "C" void f () {}
  }
</PRE>
As far as I can tell, this is not precluded by the ODR section
(3.2
 [basic.def.odr])
or the extern "C" section (7.5
 [dcl.link]).
However, I believe many compilers
do not do name mangling on variables and (more-or-less by definition)
on extern "C" functions.  That means the variable and the function
in the above end up having the same name at link time.  EDG's front
end, g++, and the Sun compiler all get essentially the same error,
which is a compile-time assembler-level error because of the
duplicate symbols (in other words, they fail to check for this, and the
assembler complains).  MSVC++ 7 links the program without error,
though I'm not sure how it is interpreted.</P>

<P>Do we intend for this case to be valid?  If not, is it a compile time
error (required), or some sort of ODR violation (no diagnostic
required)?  If we do intend for it to be valid, are we forcing
many implementations to break binary compatibility by requiring
them to mangle variable names?</P>

<P>Personally, I favor a compile-time error, and an ODR prohibition on
such things in separate translation units.</P>

<P><B>Notes from the 4/02 meeting:</B></P>

<P>The working group agreed with the proposal.  We feel a diagnostic
should be required for declarations within one translation unit.
We also noted that if the variable in global scope in the above example
were declared static we would still expect an error.</P>

<P>Relevant sections in the
standard are 7.5
 [dcl.link] paragraph 6 and
3.5
 [basic.link] paragraph 9.  We feel that the definition
should be written such that the entities in conflict are not "the same
entity" but merely not allowed together.</P>

<P><B>Additional note (September, 2004)</B></P>

<P>This problem need not involve a conflict between a function
and a variable; it can also arise with two variable
declarations:</P>

<PRE>
    int x;
    namespace N {
        extern "C" int x;
    }
</PRE>

<P><B>Proposed resolution (March, 2008):</B></P>

<P>Change 7.5
 [dcl.link] paragraph 6 as follows:</P>

<BLOCKQUOTE>

<P>At most one function with a particular name can have C
language linkage. Two declarations for a function with C language
linkage with the same function name (ignoring the namespace names
that qualify it) that appear in different namespace scopes refer
to the same function. Two declarations for an object with C
language linkage with the same name (ignoring the namespace names
that qualify it) that appear in different namespace scopes refer
to the same object. <B>A function or object with C linkage shall
not be declared with the same name (clause 3
 [basic]) as an object or reference declared in global scope,
unless both declarations denote the same object; no diagnostic is
required if the declarations appear in different translation
units.</B> [<I>Note:</I> <S>because of the one definition rule
(3.2
 [basic.def.odr]), only</S> <B>Only</B> one definition
for a function or object with C linkage may appear in the program
<B>(see 3.2
 [basic.def.odr])</B>; that <S>is,</S> <B>implies
that</B> such a function or object must not be defined in more
than one namespace scope. For example,</P>

<PRE>
    <B>int x;</B>
    namespace A {
      extern "C" int f();
      extern "C" int g() { return 1; }
      extern "C" int h();
      <B>extern "C" int x();               //<SPAN STYLE="font-family:Times"><I> ill-formed: same name as global-scope object </I></SPAN>x</B>
    }

    namespace B {
      extern "C" int f();               //<SPAN STYLE="font-family:Times"><I> </I></SPAN>A::f<SPAN STYLE="font-family:Times"><I> and </I></SPAN>B::f<SPAN STYLE="font-family:Times"><I> refer</I></SPAN>
                                        //<SPAN STYLE="font-family:Times"><I> to the same function</I></SPAN>
      extern "C" int g() { return 1; }  //<SPAN STYLE="font-family:Times"><I> ill-formed, the function </I></SPAN>g
                                        //<SPAN STYLE="font-family:Times"><I> with C language linkage</I></SPAN>
                                        //<SPAN STYLE="font-family:Times"><I> has two definitions</I></SPAN>
    }

    int A::f() { return 98; }           //<SPAN STYLE="font-family:Times"><I> definition for the function </I></SPAN>f
                                        //<SPAN STYLE="font-family:Times"><I> with C language linkage</I></SPAN>
    extern "C" int h() { return 97; }
                                        //<SPAN STYLE="font-family:Times"><I> definition for the function </I></SPAN>h
                                        //<SPAN STYLE="font-family:Times"><I> with C language linkage</I></SPAN>
                                        //<SPAN STYLE="font-family:Times"><I> </I></SPAN>A::h<SPAN STYLE="font-family:Times"><I> and </I></SPAN>::h<SPAN STYLE="font-family:Times"><I> refer to the same function</I></SPAN>
</PRE>

<P>&#8212;<I>end note</I>]</P>

</BLOCKQUOTE>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>It should also be possible to declare references with C name
linkage (although the meaning the first sentence of 7.5
 [dcl.link] paragraph 1 with respect to the meaning of such a
declaration is not clear), which would mean that the changed
wording should refer to declaring &#8220;the same entity&#8221;
instead of &#8220;the same object.&#8221; The formulation here
would probably benefit from the approach currently envisioned for
issues <A HREF="
     cwg_active.html#570">570</A> and <A HREF="
     cwg_active.html#633">633</A>, in which &#8220;variable&#8221; is defined as being
either an object or a reference.</P>

<BR><BR><HR><A NAME="374"></A><H4>374.
  
Can explicit specialization outside namespace use qualified name?
</H4><B>Section: </B>8.3&#160;
 [dcl.meaning]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Adamczyk
 &#160;&#160;&#160;

 <B>Date: </B>23 August 2002<BR>


<P>This case is nonstandard by 8.3
 [dcl.meaning] paragraph 1
(there is a requirement that the specialization first be declared within
the namespace before being defined outside of the namespace),
but probably should be allowed:</P>
<PRE>
  namespace NS1 {
    template&lt;class T&gt;
    class CDoor {
    public:
      int mtd() { return 1; }
    };
  }
  template&lt;&gt; int NS1::CDoor&lt;char&gt;::mtd()
  {
    return 0;
  }
</PRE>

<P><B>Notes from October 2002 meeting:</B></P>

<P>There was agreement that we wanted to allow this.</P>

<BR><BR><HR><A NAME="453"></A><H4>453.
  
References may only bind to &#8220;valid&#8221; objects
</H4><B>Section: </B>8.3.2&#160;
 [dcl.ref]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Gennaro Prota
 &#160;&#160;&#160;

 <B>Date: </B>18 Jan 2004<BR>


<P>8.3.2
 [dcl.ref] paragraph 4 says:</P>
<BLOCKQUOTE>
  A reference shall be initialized to refer to a valid object or
  function. [Note: in particular, a null reference cannot exist
  in a well-defined program, because the only way to create such
  a reference would be to bind it to the "object" obtained by
  dereferencing a null pointer, which causes undefined behavior
  ...]
</BLOCKQUOTE>
<P>What is a "valid" object? In particular the expression "valid object"
seems to exclude uninitialized objects, but the response to Core Issue
363 clearly says that's not the intent. This is an example
(overloading construction on constness of *this) by John Potter, which
I think is supposed to be legal C++ though it binds references to
objects that are not initialized yet:</P>
<PRE>
 struct Fun {
    int x, y;
    Fun (int x, Fun const&amp;) : x(x), y(42) { }
    Fun (int x, Fun&amp;) : x(x), y(0) { }
  };
  int main () {
    const Fun f1 (13, f1);
    Fun f2 (13, f2);
    cout &lt;&lt; f1.y &lt;&lt; " " &lt;&lt; f2.y &lt;&lt; "\n";
  }
</PRE>

<P>Suggested resolution: Changing the final part of
8.3.2
 [dcl.ref] paragraph 4 to:</P>
<BLOCKQUOTE>
  A reference shall be initialized to refer to an object or function.
  From its point of declaration on (see 3.3.1
 [basic.scope.pdecl])
  its name is an lvalue
  which refers to that object or function. The reference may be
  initialized to refer to an uninitialized object but, in that case,
  it is usable in limited ways (3.8
 [basic.life], paragraph 6)
  [Note: On the other hand, a declaration like this:
<PRE>
    int &amp; ref = *(int*)0;
</PRE>
  is ill-formed because ref will not refer to any object or function
  ]
</BLOCKQUOTE>

<P>I also think a "No diagnostic is required." would better be added
(what about something like int&amp; r = r; ?)</P>

<P><B>Proposed Resolution (October, 2004):</B></P>

<P>(Note: the following wording depends on the proposed
resolution for <A HREF="
     cwg_active.html#232">issue 232</A>.)</P>

<P>Change 8.3.2
 [dcl.ref] paragraph 4 as follows:</P>
<BLOCKQUOTE>

<P><S>A reference shall be initialized to refer to a valid object
or function.</S> <B>If an lvalue to which a reference is directly
bound designates neither an existing object or function of an
appropriate type (8.5.3
 [dcl.init.ref]), nor a region of
memory of suitable size and alignment to contain an object of the
reference's type (1.8
 [intro.object], 3.8
 [basic.life], 3.9
 [basic.types]), the behavior is
undefined.</B> [<I>Note:</I> in particular, a null reference cannot
exist in a well-defined program, because the only way to create
such a reference would be to bind it to the
<S>&#8220;object&#8221;</S> <B>empty lvalue</B> obtained by
dereferencing a null pointer, which <S>causes undefined behavior.
As</S> <B>does not designate an object or function.  Also, as
</B> described in 9.6
 [class.bit],
a reference cannot be bound directly to a
bit-field. ]</P>

<P><B>The name of a reference shall not be used in its own
initializer.  Any other use of a reference before it is
initialized results in undefined behavior.  [<I>Example:</I>
</B></P>

<B>
<PRE>
  int&amp; f(int&amp;);
  int&amp; g();

  extern int&amp; ir3;
  int* ip = 0;

  int&amp; ir1 = *ip;     // <I>undefined behavior: null pointer</I>
  int&amp; ir2 = f(ir3);  // <I>undefined behavior: </I>ir3<I> not yet initialized</I>
  int&amp; ir3 = g();
  int&amp; ir4 = f(ir4);  // <I>ill-formed: </I>ir4<I> used in its own initializer</I>
</PRE>
&#8212;<I>end example</I>]
</B>
</BLOCKQUOTE>

<P><B>Rationale: </B> The proposed wording goes beyond the specific
concerns of the issue, primarily in response to messages 10498-10506
on the core reflector.  It was noted that, while the current wording
makes cases like <TT>int&amp; r = r;</TT> ill-formed
(because <TT>r</TT> in the initializer does not "refer to a
valid object"), an inappropriate initialization can only be
detected, if at all, at runtime and thus "undefined
behavior" is a more appropriate treatment.  Nevertheless, it was
deemed desirable to continue to require a diagnostic for obvious
compile-time cases.
</P>

<P>It was also noted that the current Standard does not say anything
about using a reference before it is initialized.  It seemed
reasonable to address both of these concerns in the same wording
proposed to resolve this issue.
</P>

<P><B>Notes from the April, 2005 meeting:</B></P>

<P>The CWG decided that whether to require an implementation to
diagnose initialization of a reference to itself should be handled as
a separate issue (<A HREF="
     cwg_active.html#504">504</A>) and also suggested referring
to &#8220;storage&#8221; instead of &#8220;memory&#8221; (because
1.8
 [intro.object] defines an object as a &#8220;region of
storage&#8221;).</P>

<P><B>Proposed Resolution (April, 2005):</B></P>

<P>(Note: the following wording depends on the proposed
resolution for <A HREF="
     cwg_active.html#232">issue 232</A>.)</P>

<P>Change 8.3.2
 [dcl.ref] paragraph 4 as follows:</P>
<BLOCKQUOTE>

<P><S>A reference shall be initialized to refer to a valid object
or function.</S> <B>If an lvalue to which a reference is directly
bound designates neither an existing object or function of an
appropriate type (8.5.3
 [dcl.init.ref]), nor a region of
storage of suitable size and alignment to contain an object of the
reference's type (1.8
 [intro.object], 3.8
 [basic.life], 3.9
 [basic.types]), the behavior is
undefined.</B> [<I>Note:</I> in particular, a null reference cannot
exist in a well-defined program, because the only way to create
such a reference would be to bind it to the
<S>&#8220;object&#8221;</S> <B>empty lvalue</B> obtained by
dereferencing a null pointer, which <S>causes undefined behavior.
As</S> <B>does not designate an object or function.  Also, as
</B> described in 9.6
 [class.bit],
a reference cannot be bound directly to a
bit-field. ]</P>

<P><B>Any use of a reference before it is initialized results in
undefined behavior.  [<I>Example:</I>
</B></P>

<B>
<PRE>
  int&amp; f(int&amp;);
  int&amp; g();

  extern int&amp; ir3;
  int* ip = 0;

  int&amp; ir1 = *ip;     // <SPAN STYLE="font-family:Times"><I>undefined behavior: null pointer</I></SPAN>
  int&amp; ir2 = f(ir3);  // <SPAN STYLE="font-family:Times"><I>undefined behavior: </I></SPAN>ir3<SPAN STYLE="font-family:Times"><I> not yet initialized</I></SPAN>
  int&amp; ir3 = g();
  int&amp; ir4 = f(ir4);  // <SPAN STYLE="font-family:Times"><I>undefined behavior: </I></SPAN>ir4<SPAN STYLE="font-family:Times"><I> used in its own initializer</I></SPAN>
</PRE>
&#8212;<I>end example</I>]
</B>
</BLOCKQUOTE>

<P><B>Note (February, 2006):</B></P>

<P>The word &#8220;use&#8221; in the last
paragraph of the proposed resolution was intended to refer to the
description in 3.2
 [basic.def.odr] paragraph 2.  However, that
section does not define what it means for a reference to be
&#8220;used,&#8221; dealing only with objects and functions.  Additional
drafting is required to extend 3.2
 [basic.def.odr] paragraph 2
to apply to references.  </P>

<P><B>Additional note (May, 2008):</B></P>

<P>The proposed resolution for <A HREF="
     cwg_active.html#570">issue 570</A>
adds wording to define &#8220;use&#8221; for references.</P>

<BR><BR><HR><A NAME="701"></A><H4>701.
  
When is the array-to-pointer conversion applied?
</H4><B>Section: </B>8.3.4&#160;
 [dcl.array]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Eelis van der Weegen
 &#160;&#160;&#160;

 <B>Date: </B>13 July, 2008<BR>


<P>Paragraph 7 of 8.3.4
 [dcl.array] says,</P>

<BLOCKQUOTE>

If <TT>E</TT> is an <I>n</I>-dimensional array of rank <I>i</I>
&#215; <I>j</I> &#215; ... &#215; <I>k</I>, then <TT>E</TT>
appearing in an expression is converted to a pointer to an (<I>n</I> -
1)-dimensional array with rank <I>j</I> &#215; ... &#215;
<I>k</I>.

</BLOCKQUOTE>

<P>This formulation does not allow for the existence of expressions
in which the array-to-pointer conversion does <I>not</I> occur
(as specified in clause 5
 [expr] paragraph 9).  This
paragraph should be no more than a note, if it appears at all, and
the wording should be corrected.</P>

<BR><BR><HR><A NAME="393"></A><H4>393.
  
Pointer to array of unknown bound in template argument list in parameter
</H4><B>Section: </B>8.3.5&#160;
 [dcl.fct]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mark Mitchell
 &#160;&#160;&#160;

 <B>Date: </B>12 Dec 2002<BR>


<P>EDG rejects this code:
<PRE>
  template &lt;typename T&gt;
  struct S {};

  void f (S&lt;int (*)[]&gt;);
</PRE>
G++ accepts it.</P>

<P>This is another case where the standard isn't very clear:</P>

<P>The language from 8.3.5
 [dcl.fct] is:
 <BLOCKQUOTE>
   If the type of a parameter includes a type of the form "pointer to
   array of unknown bound of T" or "reference to array of unknown bound
   of T," the program is ill-formed.
 </BLOCKQUOTE>
 Since "includes a type" is not a term defined in the standard, we're
 left to guess what this means.  (It would be better if this were a
 recursive definition, the way a type theoretician would do it:
 <UL>
 <LI> Every type includes itself. </LI>
 <LI> T* includes T </LI>
 <LI> T[] includes T </LI>
 <LI> ... </LI>
 </UL>
 )
 </P>

<P><B>Notes from April 2003 meeting:</B></P>

<P>We agreed that the example should be allowed.</P>

<BR><BR><HR><A NAME="508"></A><H4>508.
  
Non-constructed value-initialized objects
</H4><B>Section: </B>8.5&#160;
 [dcl.init]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alisdair Meredith
 &#160;&#160;&#160;

 <B>Date: </B>18 Mar 2005<BR>


<P>According to the definition of <I>value initialization</I>
(8.5
 [dcl.init] paragraph 5), non-union class types without
user-declared constructors are value-initialized by value-initializing
each of their members rather than by executing the (generated)
default constructor.  However, a number of other items in the
Standard are described in relationship to the execution of the
constructor:</P>

<UL>

<LI><P>12.4
 [class.dtor] paragraph 6: &#8220;Bases and
members are destroyed in the reverse order of the completion of their
constructor.&#8221;  If a given base or member is value-initialized without
running its constructor, is it destroyed?  (For that matter, paragraph
10 refers to &#8220;constructed&#8221; objects; is an object that is
value-initialized without invoking a constructor
&#8220;constructed?&#8221;)</P></LI>

<LI><P>15.2
 [except.ctor] paragraph 2: &#8220;An object that is
partially constructed or partially destroyed will have destructors
executed for all of its fully constructed subobjects, that is, for
subobjects for which the constructor has completed
execution...&#8221;</P></LI>

<LI><P>3.8
 [basic.life] paragraph 1: The lifetime of an
object begins when &#8220;the constructor call has completed.&#8221;
(In the TC1 wording&#160;&#8212; &#8220;if <TT>T</TT> is a class type
with a non-trivial constructor (12.1
 [class.ctor]), the
constructor call has completed&#8221;&#160;&#8212; the lifetime of
some value-initialized objects never began; in the current wording
&#8212;&#160;&#8220;the constructor invoked to create the object is
non-trivial&#8221;&#160;&#8212; the lifetime begins before any of the
members are initialized.)</P></LI>

</UL>

<P><B>Proposed resolution (October, 2005):</B></P>

<P>Add the indicated words to 8.5
 [dcl.init] paragraph 6:</P>

<BLOCKQUOTE>

A program that calls for default-initialization or
value-initialization of an entity of reference type is ill-formed. If
<TT>T</TT> is a cv-qualified type, the cv-unqualified version
of <TT>T</TT> is used for these definitions of zero-initialization,
default-initialization, and value-initialization. <B>Even when
value-initialization of an object does not call that object's
constructor, the object is deemed to have been fully constructed once
its initialization is complete and thus subject to provisions of this
International Standard applying to &#8220;constructed&#8221; objects,
objects &#8220;for which the constructor has completed
execution,&#8221; etc.</B>

</BLOCKQUOTE>

<P><B>Notes from April, 2006 meeting:</B></P>

<P>There was some concern about whether this wording covered (or
needed to cover) cases where an object is &#8220;partially
constructed.&#8221;  Another approach might be simply to define
value initialization to be &#8220;construction.&#8221;  Returned to
&#8220;drafting&#8221; status for further investigation.</P>

<BR><BR><HR><A NAME="615"></A><H4>615.
  
Incorrect description of variables that can be initialized
</H4><B>Section: </B>8.5&#160;
 [dcl.init]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>comp.std.c++
 &#160;&#160;&#160;

 <B>Date: </B>30 January 2007<BR>


<P>8.5
 [dcl.init] paragraph 2 reads,</P>

<BLOCKQUOTE>

Automatic, register, static, and external variables of namespace scope
can be initialized by arbitrary expressions involving literals and
previously declared variables and functions.

</BLOCKQUOTE>

<P>Both &#8220;automatic&#8221; and &#8220;static&#8221; are used to
describe <I>storage durations</I>, &#8220;register&#8221; is
a <I>storage class specifier</I> which indicates the object has
automatic storage duration, &#8220;external&#8221;
describes <I>linkage</I>, and &#8220;namespace scope&#8221; is a kind
of <I>scope</I>. Automatic, register, static and external, together
with namespace scope, are used to restrict the
&#8220;variables.&#8221;</P>

<P>Register objects are only a sub-set of automatic objects and thus
the word &#8220;register&#8221; is redundant and should be elided. If
register objects are to be emphasized, they should be mentioned like
&#8220;Automatic (including register)...&#8221;</P>

<P>Variables having namespace scope can never be automatic; they can
only be static, with either external or internal linkage. Therefore,
there are in fact no &#8220;automatic variables of namespace
scope,&#8221; and the &#8220;static&#8221; in &#8220;static variables
of namespace scope&#8221; is useless.</P>

<P>In fact, automatic and static variables already compose all
variables with either external linkage or not, and thus the
&#8220;external&#8221; becomes redundant, too, and the quoted sentence
seems to mean that all variables of namespace scope can be initialized
by arbitrary expressions. But this is not true because not all
internal variables of namespace scope can. Therefore, the restrictive
&#8220;external&#8221; is really necessary, not redundant.</P>

<P>As a result, the erroneous restrictive &#8220;automatic, register,
static&#8221; should be removed and the quoted sentence may be changed
to:</P>

<BLOCKQUOTE>

External variables of namespace scope can be initialized by arbitrary
expressions involving literals and previously declared variables and
functions.

</BLOCKQUOTE>

<P><B>Notes from the April, 2007 meeting:</B></P>

<P>This sentence is poorly worded, but the analysis given in
the issue description is incorrect.  The intent is simply that
the storage class of a variable places no restrictions on the
kind of expression that can be used to initialize it (in contrast
to C, where variables of static storage duration can only be
initialized by constant expressions).</P>

<P><B>Proposed resolution (June, 2008):</B></P>

<P>Change 8.5
 [dcl.init] paragraph 2 as follows:</P>

<BLOCKQUOTE>

<S>Automatic, register, static, and external variables of namespace scope</S>
<B>Variables of automatic, thread, and static storage duration</B> can
be initialized by arbitrary expressions involving literals and
previously declared variables and functions...

</BLOCKQUOTE>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>The existing wording is intended to exclude block-scope
<TT>extern</TT> declarations but to allow initializers in all
other forms of variable declarations.  The best way to phrase
that is probably to say that all variable definitions (except for
function parameters, where the initializer syntax is used for
default arguments) can have arbitrary expressions as
initializers, regardless of storage duration.</P>

<BR><BR><HR><A NAME="233"></A><H4>233.
  
References vs pointers in UDC overload resolution
</H4><B>Section: </B>8.5.3&#160;
 [dcl.init.ref]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Matthias Meixner
 &#160;&#160;&#160;

 <B>Date: </B>9 Jun 2000<BR>


<P>There is an inconsistency in the handling of references
vs pointers in user defined conversions and overloading. The reason
for that is that the combination of 8.5.3
 [dcl.init.ref] and
4.4
 [conv.qual] circumvents the standard way of ranking
conversion functions, which was probably not the intention of the
designers of the standard.</P>

<P>Let's start with some examples, to show what it is about:</P>

<PRE>
    struct Z { Z(){} };

    struct A {
       Z x;

       operator Z *() { return &amp;x; }
       operator const Z *() { return &amp;x; }
    };

    struct B {
       Z x;

       operator Z &amp;() { return x; }
       operator const Z &amp;() { return x; }
    };

    int main()
    {
       A a;
       Z *a1=a;
       const Z *a2=a; // not ambiguous

       B b;
       Z &amp;b1=b;
       const Z &amp;b2=b; // ambiguous
    }
</PRE>

<P>So while both classes <TT>A</TT> and <TT>B</TT> are structurally
equivalent, there is a difference in operator overloading. I want to
start with the discussion of the pointer case (<TT>const Z
*a2=a;</TT>): 13.3.3
 [over.match.best] is used to select the best
viable function. Rule 4 selects <TT>A::operator const Z*()</TT> as
best viable function using 13.3.3.2
 [over.ics.rank] since the
implicit conversion sequence <TT>const Z*</TT> -&gt; <TT>const Z*</TT>
is a better conversion sequence than <TT>Z*</TT> -&gt; <TT>const
Z*</TT>.</P>

<P>So what is the difference to the reference case?  Cv-qualification
conversion is only applicable for pointers according to 4.4
 [conv.qual]. According to 8.5.3
 [dcl.init.ref] paragraphs
4-7 references are initialized by binding using the concept of
reference-compatibility. The problem with this is, that in this
context of binding, there is no conversion, and therefore there is
also no comparing of conversion sequences. More exactly all
conversions can be considered identity conversions according to
13.3.3.1.4
 [over.ics.ref] paragraph 1, which compare equal
and which has the same effect.  So binding <TT>const Z*</TT> to
<TT>const Z*</TT> is as good as binding <TT>const Z*</TT> to
<TT>Z*</TT> in terms of overloading. Therefore <TT>const Z
&amp;b2=b;</TT> is ambiguous.  [13.3.3.1.4
 [over.ics.ref]
paragraph 5 and 13.3.3.2
 [over.ics.rank] paragraph 3 rule 3
(S1 and S2 are reference bindings ...) do not seem to apply to this
case]</P>

<P>There are other ambiguities, that result in the special treatment
of references: Example:</P>

<PRE>
    struct A {int a;};
    struct B: public A { B() {}; int b;};

    struct X {
       B x;
       operator A &amp;() { return x; }
       operator B &amp;() { return x; }
    };

    main()
    {
       X x;
       A &amp;g=x; // ambiguous
    }
</PRE>

<P>Since both references of class <TT>A</TT> and <TT>B</TT> are
reference compatible with references of class <TT>A</TT> and since
from the point of ranking of implicit conversion sequences they are
both identity conversions, the initialization is ambiguous.
</P>

<P>So why should this be a defect?</P>

<UL>

<LI>References behave fundamentally different from pointers in combination 
with user defined conversions, although there is no reason to have this
different treatment.</LI>

<LI>This difference only shows up in combination with user defined
conversion sequences, for all other cases, there are special rules,
e.g. 13.3.3.2
 [over.ics.rank] paragraph 3 rule 3.</LI>

</UL>

<P>So overall I think this was not the intention of the authors of the
standard.</P>

<P>So how could this be fixed? For comparing conversion sequences (and
only for comparing) reference binding should be treated as if it was a
normal assignment/initialization and cv-qualification would have to be
defined for references. This would affect 8.5.3
 [dcl.init.ref] paragraph 6, 4.4
 [conv.qual] and probably
13.3.3.2
 [over.ics.rank] paragraph 3.</P>

<P>Another fix could be to add a special case in 13.3.3
 [over.match.best] paragraph 1. </P>

<BR><BR><HR><A NAME="589"></A><H4>589.
  
Direct binding of class and array rvalues in reference initialization
</H4><B>Section: </B>8.5.3&#160;
 [dcl.init.ref]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Adamczyk
 &#160;&#160;&#160;

 <B>Date: </B>26 July 2006<BR>


<P>The resolutions of issues <A HREF="
     cwg_defects.html#391">391</A> and
<A HREF="
     cwg_defects.html#450">450</A> say that the reference is
&#8220;bound to&#8221; the class or array rvalue, but it does not
say that the reference &#8220;binds directly&#8221; to the
initializer, as it does for the cases that fall under the first
bullet in 8.5.3
 [dcl.init.ref] paragraph 5.  However,
this phrasing is important in determining the implicit
conversion sequence for an argument passed to a parameter with
reference type (13.3.3.1.4
 [over.ics.ref]), where
paragraph 2 says,</P>

<BLOCKQUOTE>

When a parameter of reference type is not bound directly to an
argument expression, the conversion sequence is the one required
to convert the argument expression to the underlying type of the
reference according to 13.3.3.1
 [over.best.ics]. Conceptually, this conversion sequence
corresponds to copy-initializing a temporary of the underlying
type with the argument expression.

</BLOCKQUOTE>

<P>The above-mentioned issue resolutions stated that no copy
is to be made in such reference initializations, so the
determination of the conversion sequence does not reflect the
initialization semantics.</P>

<P>Simply using the &#8220;binds directly&#8221; terminology in
the new wording may not be the right approach, however, as there
are other places in the Standard that also give special treatment
to directly-bound references.  For example, the first bullet of
5.16
 [expr.cond] paragraph 3 says,</P>

<BLOCKQUOTE>

If <TT>E2</TT> is an lvalue: <TT>E1</TT> can be converted to
match <TT>E2</TT> if <TT>E1</TT> can be implicitly converted
(clause 4
 [conv]) to the type &#8220;reference to
<TT>T2</TT>,&#8221; subject to the constraint that in the
conversion the reference must bind directly (8.5.3
 [dcl.init.ref]) to <TT>E1</TT>.

</BLOCKQUOTE>

<P>The effect of simply saying that a reference &#8220;binds
directly&#8221; to a class rvalue can be seen in this example:</P>

<PRE>
    struct B { };
    struct D: B { };
    D f();
    void g(bool x, const B&amp; br) {
        x ? f() : br;   //<SPAN STYLE="font-family:Times"><I> result would be lvalue</I></SPAN>
    }
</PRE>

<P>It is not clear that treating this conditional expression as an
lvalue is a desirable outcome, even if the result of <TT>f()</TT>
were to &#8220;bind directly&#8221; to the <TT>const B&amp;</TT>
reference.</P>

<BR><BR><HR><A NAME="664"></A><H4>664.
  
Direct binding of references to non-class rvalue references
</H4><B>Section: </B>8.5.3&#160;
 [dcl.init.ref]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Eric Niebler
 &#160;&#160;&#160;

 <B>Date: </B>1 December 2007<BR>




<P>According to 8.5.3
 [dcl.init.ref] paragraph 5, a reference
initialized with a reference-compatible rvalue of class type binds
directly to the object.  A reference-compatible non-class rvalue
reference, however, is first copied to a temporary and the reference
binds to that temporary, not to the target of the rvalue reference.
This can cause problems when the result of a forwarding function is
used in such a way that the address of the result is captured.  For
example:</P>

<PRE>
    struct ref {
        explicit ref(int&amp;&amp; i): p(&amp;i) { }
        int* p;
    };

    int&amp;&amp; forward(int&amp;&amp; i) {
        return i;
    }

    void f(int&amp;&amp; i) {
        ref r(forward(i));
        //<SPAN STYLE="font-family:Times"><I> Here </I></SPAN>r.p<SPAN STYLE="font-family:Times"><I> is a dangling pointer, pointing to a defunct </I></SPAN>int<SPAN STYLE="font-family:Times"><I> temporary</I></SPAN>
    }
</PRE>

<P>A formulation is needed so that rvalue references are treated like
class and array rvalues.</P>

<P><B>Notes from the February, 2008 meeting:</B></P>

<P>You can't just treat scalar rvalues like class and array rvalues,
because they might not have an associated object.  However, if you have
an rvalue reference, you know that there is an object, so probably the
best way to address this issue is to specify somehow that binding a
reference to an rvalue reference does not introduce a new temporary.</P>

<P>(See also <A HREF="
     cwg_active.html#690">issue 690</A>.)</P>

<BR><BR><HR><A NAME="703"></A><H4>703.
  
Narrowing for literals that cannot be exactly represented
</H4><B>Section: </B>8.5.4&#160;
 [dcl.init.list]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jason Merrill
 &#160;&#160;&#160;

 <B>Date: </B>2 July, 2008<BR>




<P>Both of the following initializations are ill-formed because of
narrowing, although they were previously well-formed:</P>

<PRE>
    struct A { int i; } a = { 1.0 };
    struct B { float f; } b = { 1.1 };
</PRE>

<P>The first one doesn't seem like a big problem, as there probably
isn't much code that has this kind of aggregate initialization.  The
second might be of more concern, because <TT>1.1</TT> is not
representable in either <TT>float</TT> or <TT>double</TT>.  Is the
resulting loss of precision a kind of narrowing that we want to
diagnose?</P>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>The CWG agreed that the second initialization should not be a
narrowing error; furthermore, this exemption should apply not
only to literals but to any floating-point constant expression.
Instead of the current formulation, requiring exact bidirectional
convertibility, the Standard should only require that the
initializer value be within the representable range of the target
type.</P>

<BR><BR><HR><A NAME="580"></A><H4>580.
  
Access in <I>template-parameter</I>s of member and friend definitions
</H4><B>Section: </B>11&#160;
 [class.access]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>16 May 2006<BR>


<P>The resolution of <A HREF="
     cwg_defects.html#372">issue 372</A> leaves
unclear whether the following are well-formed or not:</P>

<PRE>
    class C {
        typedef int I;                // private
        template &lt;int&gt; struct X;
        template &lt;int&gt; friend struct Y;
    }

    template &lt;C::I&gt; struct C::X { };  // C::I accessible to member?

    template &lt;C::I&gt; struct Y { };     // C::I accessible to friend?
</PRE>

<P>Presumably the answer to both questions is &#8220;yes,&#8221; but
the new wording does not address <I>template-parameter</I>s.</P>

<P><B>Proposed resolution (June, 2008):</B></P>

<P>Change 11
 [class.access] paragraph 6 as follows:</P>

<BLOCKQUOTE>

...For purposes of access control, the <I>base-specifier</I>s of a class<B>, the
<I>template-parameter</I>s of a <I>template-declaration</I>,</B> and
the definitions of class members that appear outside of the class
definition are considered to be within the scope of that class...

</BLOCKQUOTE>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>The proposed resolution preserves the word &#8220;scope&#8221;
as a holdover from the original specification prior to <A HREF="
     cwg_defects.html#372">issue 372</A>, which intended to change access
determination from a scope-based model to an entity-based model.
The resolution should eliminate all references to scope and simply
use the entity-based model.</P>

<P>(See also <A HREF="
     cwg_active.html#718">issue 718</A>.)</P>

<BR><BR><HR><A NAME="472"></A><H4>472.
  
Casting across protected inheritance
</H4><B>Section: </B>11.5&#160;
 [class.protected]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>16 Jun 2004<BR>


<P>Does the restriction in 11.5
 [class.protected] apply to
upcasts across protected inheritance, too?  For instance,</P>

<PRE>
    struct B {
        int i;
    };
    struct I: protected B { };
    struct D: I {
        void f(I* ip) {
            B* bp = ip;    // well-formed?
            bp-&gt;i = 5;     // aka "ip-&gt;i = 5;"
        }
    };
</PRE>

<P>I think the rationale for the 11.5
 [class.protected]
restriction applies equally well here &#8212; you don't know whether
<TT>ip</TT> points to a <TT>D</TT> object or not, so <TT>D::f</TT> can't be trusted to treat
the protected <TT>B</TT> subobject consistently with the policies of its
actual complete object type.</P>

<P>The current treatment of &#8220;accessible base class&#8221;
in 11.2
 [class.access.base] paragraph 4
clearly makes the conversion from <TT>I*</TT> to <TT>B*</TT> well-formed.  I
think that's wrong and needs to be fixed.  The rationale for
the accessibility of a base class is whether &#8220;an invented
public member&#8221; of the base would be accessible at the point of
reference, although we obscured that a bit in the
reformulation; it seems to me that the invented member ought to
be considered a non-static member for this purpose and thus
subject to 11.5
 [class.protected].</P>

(See also issues <A HREF="
     cwg_defects.html#385">385</A> and <A HREF="
     cwg_closed.html#471">471</A>.).

<P><B>Notes from October 2004 meeting:</B></P>

<P>The CWG tentatively agreed that casting across protective
inheritance should be subject to the additional restriction in
11.5
 [class.protected].</P>



<BR><BR><HR><A NAME="399"></A><H4>399.
  
Destructor lookup redux
</H4><B>Section: </B>12.4&#160;
 [class.dtor]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>17 Jan 2003<BR>


<P>Mark Mitchell raised a number of issues related to the resolution of
<A HREF="
     cwg_defects.html#244">issue 244</A> and of destructor lookup in general.</P>

<P><A HREF="
     cwg_defects.html#244">Issue 244</A> says:</P>
<BLOCKQUOTE>
	... in a <I>qualified-id</I> of the form:
<UL>
::<SUB>opt</SUB> <I>nested-name-specifier</I><SUB>opt</SUB>
   <I>class-name</I> :: ~ <I>class-name</I>
</UL>
	the second class-name is looked up in the same scope as the first.
</BLOCKQUOTE>
<P>But if the reference is "<TT>p-&gt;X::~X()</TT>", the first
<I>class-name</I> is looked up
in two places (normal lookup and a lookup in the class of p).  Does
the new wording mean:
<OL>
<LI>
You look up the second class-name in the scope that you found the first
one.
</LI>
<LI>You look up the second class-name using the same kind of lookup that
   found the first one (normal vs. class).
</LI>
<LI>If you did a dual lookup for the first you do a dual lookup for the
   second.
</LI>
</OL>
</P>

<P>This is a test case that illustrates the issue:</P>
<PRE>
  struct A {
    typedef A C;
  };

  typedef A B;

  void f(B* bp) {
    bp-&gt;B::~B();  // okay B found by normal lookup
    bp-&gt;C::~C();  // okay C found by class lookup
    bp-&gt;B::~C();  // B found by normal lookup C by class -- okay?
    bp-&gt;C::~B();  // C found by class lookup B by normal -- okay?
  }
</PRE>

<P>A second issue concerns destructor references when the class involved is
a template class.</P>
<PRE>
  namespace N {
    template &lt;typename T&gt; struct S {
      ~S();
    };
  }

  void f(N::S&lt;int&gt;* s) {
    s-&gt;N::S&lt;int&gt;::~S();
  }
</PRE>
<P>The issue here is that the grammar uses "~<I>class-name</I>" for destructor
names, but in this case S is a template name when looked up in N.</P>

<P>Finally, what about cases like:</P>
<PRE>
  template &lt;typename T&gt; void f () {
    typename T::B x;
    x.template A&lt;T&gt;::template B&lt;T&gt;::~B();
  }
</PRE>
<P>When parsing the template definition, what checks can be done on "~B"?</P>

<P><U>Sandor Mathe</U> adds
:</P>

<P>The standard correction for <A HREF="
     cwg_defects.html#244">issue 244</A>
(now in DR status) is still incomplete.</P>

<P>Paragraph 5 of 3.4.3
 [basic.lookup.qual] is
not applicable for p-&gt;T::~T since there is no nested-name-specifier.
Section 3.4.5
 [basic.lookup.classref]
describes the lookup of p-&gt;~T but p-&gt;T::~T is still not
described.  There are examples (which are non-normative) that illustrate
this sort of lookup but they still leave questions unanswered.  The
examples imply that the name after ~ should be looked up in the same
scope as the name before the :: but it is not stated.  The problem is
that the name to the left of the :: can be found in two
different scopes.  Consider the following:</P>
<PRE>
  struct S {
    struct C { ~C() { } };
  };

  typedef S::C D;

  int main() {
    D* p;
    p-&gt;C::~D();  // valid?
  }
</PRE>

<P>Should the destructor call be valid?  If there were a nested name
specifier, then D should be looked for in the same scope as C.  But
here, C is looked for in 2 different ways.  First, it is searched for in
the type of the left hand side of -&gt; and it is also looked for in the
lexical context.  It is found in one or if both, they must match.  So, C
is found in the scope of what p points at.  Do you only look for D there?
If so, this is invalid.  If not, you would then look for D in the context
of the expression and find it.  They refer to the same underlying
destructor so this is valid.  The intended resolution of the original
defect report of the standard was that the name before the :: did not
imply a scope and you did not look for D inside of C.  However, it was
not made clear whether this was to be resolved by using the same lookup
mechanism or by introducing a new form of lookup which is to look in the
left hand side if that is where C was found, or in the context of the
expression if that is where C was found.  Of course, this begs the
question of what should happen when it is found in both?  Consider
the modification to the above case when C is also found in the context
of the expression.  If you only look where you found C, is this now
valid because it is in 1 of the two scopes or is it invalid because C
was in both and D is only in 1?</P>

<PRE>
  struct S {
    struct C { ~C() { } };
  };

  typedef S::C D;
  typedef S::C C;

  int main() {
    D* p;
    p-&gt;C::~D();  // valid?
  }
</PRE>

<P>I agree that the intention of the committee is that the original test
case in this defect is broken.  The standard committee clearly thinks
that the last name before the last :: does not induce a new scope which
is our current interpretation.  However, how this is supposed to work
is not defined.  This needs clarification of the standard.</P>

<P><U>Martin Sebor</U> adds this example (September 2003), along
with errors produced by the EDG front end:</P>
<PRE>
namespace N {
    struct A { typedef A NA; };
    template &lt;class T&gt; struct B { typedef B NB; typedef T BT; };
    template &lt;template &lt;class&gt; class T&gt; struct C { typedef C NC; typedef T&lt;A&gt; CA; };
}

void foo (N::A *p)
{
    p-&gt;~NA ();
    p-&gt;NA::~NA ();
}

template &lt;class T&gt;
void foo (N::B&lt;T&gt; *p)
{
    p-&gt;~NB ();
    p-&gt;NB::~NB ();
}

template &lt;class T&gt;
void foo (typename N::B&lt;T&gt;::BT *p)
{
    p-&gt;~BT ();
    p-&gt;BT::~BT ();
}

template &lt;template &lt;class&gt; class T&gt;
void foo (N::C&lt;T&gt; *p)
{
    p-&gt;~NC ();
    p-&gt;NC::~NC ();
}

template &lt;template &lt;class&gt; class T&gt;
void foo (typename N::C&lt;T&gt;::CA *p)
{
    p-&gt;~CA ();
    p-&gt;CA::~CA ();
}

Edison Design Group C/C++ Front End, version 3.3 (Sep  3 2003 11:54:55)
Copyright 1988-2003 Edison Design Group, Inc.

"t.cpp", line 16: error: invalid destructor name for type "N::B&lt;T&gt;"
      p-&gt;~NB ();
          ^

"t.cpp", line 17: error: qualifier of destructor name "N::B&lt;T&gt;::NB" does not
          match type "N::B&lt;T&gt;"
      p-&gt;NB::~NB ();
              ^

"t.cpp", line 30: error: invalid destructor name for type "N::C&lt;T&gt;"
      p-&gt;~NC ();
          ^

"t.cpp", line 31: error: qualifier of destructor name "N::C&lt;T&gt;::NC" does not
          match type "N::C&lt;T&gt;"
      p-&gt;NC::~NC ();
              ^

4 errors detected in the compilation of "t.cpp".
</PRE>

<P><U>John Spicer:</U>
The issue here is that we're unhappy with the destructor names when doing 
semantic analysis of the template definitions (not during an
instantiation).</P>

<P>My personal feeling is that this is reasonable.  After all, why 
would you call p-&gt;~NB for a class that you just named
as N::B&lt;T&gt; and you could just say p-&gt;~B?</P>

<P><B>Additional note (September, 2004)</B></P>

<P>The resolution for <A HREF="
     cwg_defects.html#244">issue 244</A> removed
the discussion of <TT>p-&gt;N::~S</TT>, where <TT>N</TT> is a
<I>namespace-name</I>.  However, the resolution did not make this
construct ill-formed; it simply left the semantics undefined.
The meaning should either be defined or the construct made
ill-formed.</P>

<P>See also issues <A HREF="
     cwg_defects.html#305">305</A> and
<A HREF="
     cwg_defects.html#466">466</A>.</P>

<BR><BR><HR><A NAME="655"></A><H4>655.
  
Initialization not specified for forwarding constructors
</H4><B>Section: </B>12.6.2&#160;
 [class.base.init]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alisdair Meredith
 &#160;&#160;&#160;

 <B>Date: </B>17 October 2007<BR>




<P>The changes for delegating constructors overlooked the need to
change 12.6.2
 [class.base.init] paragraph 3:</P>

<BLOCKQUOTE>

<P>The <I>expression-list</I> in a <I>mem-initializer</I> is used to
initialize the base class or non-static data member subobject denoted
by the <I>mem-initializer-id</I>. The semantics of
a <I>mem-initializer</I> are as follows:</P>

<UL>
<LI><P>if the <I>expression-list</I> of the <I>mem-initializer</I> is
omitted, the base class or member subobject is value-initialized (see
8.5
 [dcl.init]);</P></LI>

<LI><P>otherwise, the subobject indicated
by <I>mem-initializer-id</I> is direct-initialized using
<I>expression-list</I> as the <I>initializer</I> (see 8.5
 [dcl.init]).</P></LI>
</UL>

<P>The initialization of each base and member constitutes a
full-expression. Any expression in a <I>mem-initializer</I> is
evaluated as part of the full-expression that performs the
initialization.</P>

</BLOCKQUOTE>

<P>This paragraph deals only with subobjects; it needs to be made more
general to apply to the complete object as well when
the <I>mem-initializer-id</I> designates the constructor's class.</P>

<P><B>Proposed resolution (June, 2008):</B></P>

<P>Change 12.6.2
 [class.base.init] paragraph 3 as follows:</P>

<BLOCKQUOTE>

<P><S>The <I>expression-list</I> in a <I>mem-initializer</I> is used
to initialize the base class or non-static data member subobject
denoted by the <I>mem-initializer-id</I>. The semantics of a
<I>mem-initializer</I> are</S> <B>A <I>mem-initializer</I> in which the
<I>mem-initializer-id</I> names the constructor's class initializes the
object by invoking the selected target constructor with the
<I>mem-initializer</I>'s <I>expression-list</I>. A
<I>mem-initializer</I> in which the <I>mem-initializer-id</I> names a base
class or non-static data member initializes the designated subobject</B>
as follows:</P>

<UL><LI><P>if the <I>expression-list</I> of the <I>mem-initializer</I>
is omitted, the base class or member subobject is value-initialized
(see 8.5
 [dcl.init]);</P></LI>

<LI><P>otherwise, the subobject indicated by <I>mem-initializer-id</I> is
direct-initialized using <I>expression-list</I> as the initializer (see
8.5
 [dcl.init]).</P></LI>

</UL>

<P>...</P>

<P>The initialization <S>of each base and member</S> <B>performed by
each <I>mem-initializer</I></B> constitutes a full-expression. Any
expression...</P>

</BLOCKQUOTE>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>This text was significantly modified by N2756 (nonstatic data
member initializers) and needs to be reworked in light of those
changes.</P>

<BR><BR><HR><A NAME="680"></A><H4>680.
  
What is a move constructor?
</H4><B>Section: </B>12.8&#160;
 [class.copy]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Adamczyk
 &#160;&#160;&#160;

 <B>Date: </B>3 March, 2008<BR>


<P>Although the term &#8220;move constructor&#8221; appears multiple
times in the library clauses and is referenced in the newly-added
text for the lambda feature, it is not defined anywhere.</P>

<P><B>Notes from the June, 2008 meeting:</B></P>

<P>The only reference to &#8220;move constructor&#8221; in the core
language clauses of the Standard is in 5.1.1
 [expr.prim.lambda]
paragraph 10; there are no semantic implications of the term. This
issue will be addressed by using a function signature instead of the
term, thus allowing the library section to provide a definition that
is appropriate for its needs.</P>

<BR><BR><HR><A NAME="604"></A><H4>604.
  
Argument list for overload resolution in copy-initialization
</H4><B>Section: </B>13.3.1.3&#160;
 [over.match.ctor]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Dawn Perchik
 &#160;&#160;&#160;

 <B>Date: </B>4 November 2006<BR>


<P>According to 13.3.1.3
 [over.match.ctor],</P>

<BLOCKQUOTE>

When objects of class type are direct-initialized (8.5
 [dcl.init]), or copy-initialized from an expression of the
same or a derived class type (8.5
 [dcl.init])... [the] argument list is
the <I>expression-list</I> within the parentheses of the
initializer.

</BLOCKQUOTE>

<P>However, in copy initialization (using the &#8220;=&#8221;
notation), there need be no parentheses.  What is the argument list
in that case?</P>

<BR><BR><HR><A NAME="702"></A><H4>702.
  
Preferring conversion to <TT>std::initializer_list</TT>
</H4><B>Section: </B>13.3.3.2&#160;
 [over.ics.rank]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jason Merrill
 &#160;&#160;&#160;

 <B>Date: </B>2 July, 2008<BR>




<P>We need another bullet in 13.3.3.2
 [over.ics.rank], along
the lines of:</P>

<UL><LI><P>List-initialization sequence <TT>L1</TT> is a better
conversion sequence than list-initialization sequence <TT>L2</TT>
if <TT>L1</TT> converts to <TT>std::initializer_list&lt;X&gt;</TT>
for some <TT>X</TT> and <TT>L2</TT> does not.</P></LI></UL>

<P>This is necessary to make the following example work:</P>

<PRE>
    #include &lt;initializer_list&gt;

    struct string {
      string (const char *) {}
      template &lt;class Iter&gt; string (Iter, Iter);
    };

    template &lt;class T, class U&gt;
    struct pair {
      pair (T t, U u) {}
    };

    template&lt;class T, class U&gt;
    struct map {
      void insert (pair&lt;T,U&gt;);
      void insert (std::initializer_list&lt;pair&lt;T,U&gt; &gt;) {}
    };

    int main() {
      map&lt;string,string&gt; m;
      m.insert({ {"this","that"}, {"me","you"} });
    }
</PRE>

<BR><BR><HR><A NAME="260"></A><H4>260.
  
User-defined conversions and built-in <TT>operator=</TT>
</H4><B>Section: </B>13.6&#160;
 [over.built]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Scott Douglas
 &#160;&#160;&#160;

 <B>Date: </B>4 Nov 2000<BR>


<P>According to the Standard (although not implemented this way
in most implementations), the following code exhibits non-intuitive
behavior:</P>

<PRE>
  struct T {
    operator short() const;
    operator int() const;
  };

  short s;

  void f(const T&amp; t) {
    s = t;  // surprisingly calls T::operator int() const
  }
</PRE>

<P>The reason for this choice is 13.6
 [over.built]
paragraph 18:</P>

<BLOCKQUOTE>

<P>For every triple (<I>L</I>, <I>VQ</I>, <I>R</I>), where <I>L</I> is an
arithmetic type, <I>VQ</I> is either <TT>volatile</TT> or empty, and
<I>R</I> is a promoted arithmetic type, there exist candidate operator
functions of the form</P> 

<UL><I>VQ</I> <I>L</I><TT>&amp; operator=(</TT><I>VQ L</I><TT>&amp;,</TT> <I>R</I><TT>);</TT></UL>

</BLOCKQUOTE>

<P>Because <I>R</I> is a "promoted arithmetic type," the second argument
to the built-in assignment operator is <TT>int</TT>, causing the
unexpected choice of conversion function.</P>

<P><B>Suggested resolution:</B> Provide built-in assignment operators
for the unpromoted arithmetic types.</P>

<P>Related to the preceding, but not resolved by the suggested
resolution, is the following problem.  Given:</P>

<PRE>
    struct T {
	 operator int() const;
	 operator double() const;
    };
</PRE>

<P>I believe the standard requires the following assignment to be
ambiguous (even though I expect that would surprise the user):</P>

<PRE>
    double x;
    void f(const T&amp; t) { x = t; }
</PRE>

<P>The problem is that both of these built-in <TT>operator=()</TT>s exist
(13.6
 [over.built] paragraph 18):</P>

<PRE>
    double&amp; operator=(double&amp;, int);
    double&amp; operator=(double&amp;, double);
</PRE>

<P>Both are an exact match on the first argument and a user conversion
on the second.  There is no rule that says one is a better match than
the other.</P>

<P>The compilers that I have tried (even in their strictest setting)
do not give a peep.  I think they are not following the standard.
They pick <TT>double&amp; operator=(double&amp;, double)</TT> and use
<TT>T::operator double() const</TT>.</P>

<P>I hesitate to suggest changes to overload resolution, but a
possible resolution might be to introduce a rule that, for built-in
<TT>operator=</TT> only, also considers the conversion sequence from
the second to the first type.  This would also resolve the earlier
question.</P>

<P>It would still leave <TT>x += t</TT> etc. ambiguous -- which might
be the desired behavior and is the current behavior of some
compilers.</P>

<P><B>Notes from the 04/01 meeting:</B></P>

<P>The difference between initialization and assignment is
disturbing.  On the other hand, promotion is ubiquitous in the
language, and this is the beginning of a very slippery slope (as
the second report above demonstrates).
</P>

<BR><BR><HR><A NAME="205"></A><H4>205.
  
Templates and static data members
</H4><B>Section: </B>14&#160;
 [temp]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>11 Feb 2000<BR>



<P>Static data members of template classes and of nested classes of
template classes are not themselves templates but receive much the
same treatment as template.  For instance,
14
 [temp]
 paragraph 1 says that templates
are only "classes or functions" but implies that "a static data member
of a class template or of a class nested within a class template" is
defined using the <I>template-declaration</I> syntax.</P>

<P>There are many places in the clause, however, where static data
members of one sort or another are overlooked.  For instance,
14
 [temp]
 paragraph 6 allows static data
members of class templates to be declared with the <TT>export</TT>
keyword.  I would expect that static data members of (non-template)
classes nested within class templates could also be exported, but they
are not mentioned here.</P>

<P>Paragraph 8, however, overlooks static data members altogether and
deals only with "templates" in defining the effect of the
<TT>export</TT> keyword; there is no description of the semantics of
defining a static data member of a template to be exported.</P>

<P>These are just two instances of a systematic problem.  The entire
clause needs to be examined to determine which statements about
"templates" apply to static data members, and which statements about
"static data members of class templates" also apply to static data
members of non-template classes nested within class templates.</P>

<P>(The question also applies to member functions of template classes;
see <A HREF="
     cwg_defects.html#217">issue 217</A>, where the phrase
"non-template function" in 8.3.6
 [dcl.fct.default] paragraph 4
is apparently intended <I>not</I> to include non-template member
functions of template classes.  See also <A HREF="
     cwg_defects.html#108">issue 108</A>, which would benefit from understanding nested classes of
class templates as templates.  Also, see <A HREF="
     cwg_defects.html#249">issue 249</A>, in which the usage of the phrase "member function
template" is questioned.)</P>

<P><B>Notes from the 4/02 meeting:</B></P>

<P>Daveed Vandevoorde will propose appropriate terminology.</P>

<BR><BR><HR><A NAME="691"></A><H4>691.
  
Template parameter packs in class template partial specializations
</H4><B>Section: </B>14.1&#160;
 [temp.param]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Doug Gregor
 &#160;&#160;&#160;

 <B>Date: </B>9 April, 2008<BR>




<P>14.1
 [temp.param] paragraph 11 currently says,</P>

<BLOCKQUOTE>

If a <I>template-parameter</I> of a class template is a template
parameter pack, it shall be the last
<I>template-parameter</I>. [<I>Note:</I> These are not
requirements for function templates because template arguments
might be deduced (14.8.2
 [temp.deduct])...

</BLOCKQUOTE>

<P>This restriction was only meant to apply to primary class
templates, not partial specializations.</P>

<P><U>Suggested resolution</U>:</P>

<BLOCKQUOTE>

If a <I>template-parameter</I> of a <B>primary</B> class template
is a template parameter pack, it shall be the last
<I>template-parameter</I>. [<I>Note:</I> These are not
requirements for function templates <B>or class template partial
specializations</B> because template arguments might be deduced
(14.8.2
 [temp.deduct])...

</BLOCKQUOTE>

<BR><BR><HR><A NAME="96"></A><H4>96.
  
Syntactic disambiguation using the <TT>template</TT> keyword
</H4><B>Section: </B>14.2&#160;
 [temp.names]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>16 Feb 1999<BR>



<P>The following is the wording from
14.2
 [temp.names]

paragraphs 4 and 5 that discusses the use of the "template" keyword following
<TT>.</TT> or <TT>-&gt;</TT> and in qualified names.</P>
<UL>When the name of a member template specialization appears after <TT>.</TT>
or <TT>-&gt;</TT> in a <I>postfix-expression</I>, or after <I>nested-name-specifier</I>
in a <I>qualified-id</I>, and the <I>postfix-expression</I> or <I>qualified-id</I>
explicitly depends on a <I>template-parameter</I>
(14.6.2
 [temp.dep]
),
the member template name must be prefixed by the keyword <TT>template</TT>.
Otherwise the name is assumed to name a non-template. [<I>Example:</I>
<PRE>
    class X {
    public:
        template&lt;std::size_t&gt; X* alloc();
        template&lt;std::size_t&gt; static X* adjust();
    };
    
    template&lt;class T&gt; void f(T* p) {
        T* p1 = p-&gt;alloc&lt;200&gt;();
                // ill-formed: &lt; means less than
    
        T* p2 = p-&gt;template alloc&lt;200&gt;();
                // OK: &lt; starts template argument list
     
        T::adjust&lt;100&gt;();
                // ill-formed: &lt; means less than
     
        T::template adjust&lt;100&gt;();
                // OK: &lt; starts explicit qualification
    }
</PRE>
&#8212;<I>end example</I>]

<P>If a name prefixed by the keyword <TT>template</TT> is not the name
of a member template, the program is ill-formed.
[<I>Note:</I> the keyword <TT>template</TT>
may not be applied to non-template members of class templates. ]</P></UL>
The whole point of this feature is to say that the "<TT>template</TT>"
keyword is needed to indicate that a "<TT>&lt;</TT>" begins a template
parameter list in certain contexts. The constraints in paragraph 5 leave
open to debate certain cases.

<P>First, I think it should be made more clear that the template name must
be followed by a template argument list when the "<TT>template</TT>" keyword
is used in these contexts. If we don't make this clear, we would have to
add several semantic clarifications instead. For example, if you say "<TT>p-&gt;template
f()</TT>", and "<TT>f</TT>" is an overload set containing both templates
and nontemplates: a) is this valid? b) are the nontemplates in the overload
set ignored? If the user is forced to write "<TT>p-&gt;template f&lt;&gt;()</TT>"
it is clear that this is valid, and it is equally clear that nontemplates
in the overload set are ignored. As this feature was added purely to provide
syntactic guidance, I think it is important that it otherwise have no semantic
implications.</P>

<P>I propose that paragraph 5 be modified to:</P>
<UL>If a name prefixed by the keyword <TT>template</TT> is not the name
of a member template, or an overload set containing one or more member
templates, the program is ill-formed. If the name prefixed by the <TT>template</TT>
keyword is not followed by a <I>template-argument-list</I>, the program
is ill-formed.</UL>

<P>(See also <A HREF="
     cwg_defects.html#30">issue 30</A> and document
J16/00-0008 = WG21 N1231.)</P>

<P><B>Notes from 04/00 meeting:</B></P>

<P>The discussion of this issue revived interest in issues
<A HREF="
     cwg_defects.html#11">11</A> and <A HREF="
     cwg_closed.html#109">109</A>.

</P>

<P><B>Notes from the October 2003 meeting:</B></P>

<P>We reviewed John Spicer's paper N1528 and agreed with his
recommendations therein.</P>

<BR><BR><HR><A NAME="314"></A><H4>314.
  
<TT>template</TT> in base class specifier
</H4><B>Section: </B>14.2&#160;
 [temp.names]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mark Mitchell
 &#160;&#160;&#160;

 <B>Date: </B>23 Aug 2001<BR>


<P>The EDG front-end accepts:</P>
<PRE>
template &lt;typename T&gt;
struct A {
  template &lt;typename U&gt;
  struct B {};
};

template &lt;typename T&gt;
struct C : public A&lt;T&gt;::template B&lt;T&gt; {
};
</PRE>
<P>It rejects this code if the base-specifier is spelled
<TT>A&lt;T&gt;::B&lt;T&gt;</TT>.</P>

<P>However, the grammar for a base-specifier does not allow the
<TT>template</TT> keyword.</P>

<P><B>Suggested resolution:</B></P>

It seems to me that a consistent approach to the solution that looks like
it will be adopted for <A HREF="
     cwg_defects.html#180">issue 180</A> (which deals
with the <TT>typename</TT> keyword in similar contexts) would be to
assume that <TT>B</TT> is a template if it is followed by a
"&lt;".  After all, an expression cannot appear in this context.

<P><B>Notes from the 4/02 meeting:</B></P>

<P>We agreed that <TT>template</TT> must be allowed in this context.
The syntax needs to be changed.  We also opened the related
<A HREF="
     cwg_active.html#343">issue 343</A>.</P>
<BR><BR><HR><A NAME="431"></A><H4>431.
  
Defect in wording in 14.2
</H4><B>Section: </B>14.2&#160;
 [temp.names]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mat Marcus
 &#160;&#160;&#160;

 <B>Date: </B>10 August 2003<BR>




<P>Consider this example:</P>
<PRE>
   class Foo {
   public:
       template&lt; typename T &gt; T *get();
   };

   template&lt; typename U &gt;
   U *testFoo( Foo &amp;foo ) {
       return foo.get&lt; U &gt;(); //#1
   }
</PRE>
<P>I am under the impression that this should compile without requiring
the insertion of the template keyword before get in the expression at
//#1. This notion is supported by this note excerpted from
14.2
 [temp.names]/5:</P>
<BLOCKQUOTE>
   [Note: just as is the case with the typename prefix, the template
   prefix is allowed in cases where it is not strictly necessary;
   i.e.,  when the expression on the left of the -&gt; or ., or the
   nested-name-specifier is not dependent on a template parameter.]
</BLOCKQUOTE>

<P>But 14.2
 [temp.names]/4 contains this text:</P>
<BLOCKQUOTE>
   When the name of a member template specialization appears after .
   or -&gt; in a postfix-expression, or after nested-name-specifier in
   a qualified-id, and the postfix-expression or qualified-id
   explicitly depends on a template-parameter (14.6.2), the member
   template name must be prefixed by the keyword template. Otherwise
   the name is assumed to name a non-template.
</BLOCKQUOTE>

<P>The only way that I can read this to support my assumption above is if
I assume that the phrase postfix-expression is used twice above with
different meaning. That is I read the first use as referring to the
full expression while the second use refers to the subexpression
preceding the operator. Is this the correct determination of intent? I
find this text confusing. Would it be an improvement if the second
occurrence of "postfix-expression" should be replaced by "the
subexpression preceding the operator". Of course that begs the
question "where is subexpression actually defined in the standard?"</P>

<P><U>John Spicer:</U>
I agree that the code should work, and that we should tweak 
the wording.</P>

<BR><BR><HR><A NAME="408"></A><H4>408.
  
sizeof applied to unknown-bound array static data member of template
</H4><B>Section: </B>14.5.1.3&#160;
 [temp.static]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Nathan Myers
 &#160;&#160;&#160;

 <B>Date: </B>14 Apr 2003<BR>




<P>Is this allowed?</P>
<PRE>
  template&lt;typename T&gt; 
    struct X
    {
        static int s[];
        int c;
    };

  template&lt;typename T&gt;
    int X&lt;T&gt;::s[sizeof(X&lt;T&gt;)];

  int* p = X&lt;char&gt;::s;
</PRE>

<P>I have a compiler claiming that, for the purpose of sizeof(), X&lt;T&gt; is 
an incomplete type, when it tries to instantiate X&lt;T&gt;::s.  It seems to 
me that X&lt;char&gt; should be considered complete enough for sizeof even
though the size of s isn't known yet.</P>


<P><U>John Spicer:</U>
This is a problematic construct that is currently allowed but which I think 
should be disallowed.</P>

<P>I tried this with a number of compilers.
None of which did the right thing. 
The EDG front end accepts it, but gives X&lt;...&gt;::s the wrong size.</P>

<P>It appears that most compilers evaluate the
"declaration" part of the static 
data member definition only once when the definition is processed.  The 
initializer (if any) is evaluated for each instantiation.</P>

<P>This problem is solvable, and if it were
the only issue with incomplete arrays 
as template static data members, then it would make
sense to solve it, but there are other problems.</P>

<P>The first problem is that the size of the static data member is
only known if a template definition of the static data member is
present.  This is weird to start with, but it also means that sizes
would not be available in general for exported templates.</P>

<P>The second problem concerns the rules for specialization.  An explicit 
specialization for a template instance can be provided up until the
point that a use is made that would cause an implicit instantiation.
A reference like "sizeof(X&lt;char&gt;::s)" is not currently a reference
that would cause an implicit instantiation of X&lt;char&gt;::s.
This means you could use such a sizeof and later 
specialize the static data member with a different size, meaning the earlier 
sizeof gave the wrong result.  We could, of course, change the "use"
rules, but I'd rather see us require that static data members that
are arrays have a size specified in the class or have a size based
on their initializer.</P>

<P><B>Notes from the October 2003 meeting:</B></P>

<P>The example provided is valid according to the current
standard.  A static data member must be
instantiated (including the processing of its initializer, if any)
if there is any reference to it.  The compiler need not, however, put out
a definition in that translation unit.  The standard doesn't really
have a concept of a "partial instantiation" for a static data
member, and although we considered adding that, we decided that
to get all the size information that seems to be available one
needs a full instantiation in any case, so there's no need
for the concept of a partial instantiation.</P>

<P><B>Note (June, 2006):</B></P>

<P>Mark Mitchell suggested the following example:</P>

<PRE>
    template &lt;int&gt; void g();

    template &lt;typename T&gt;
    struct S {
      static int i[];
      void f();
    };

    template &lt;typename T&gt;
    int S&lt;T&gt;::i[] = { 1 };

    template &lt;typename T&gt;
    void S&lt;T&gt;::f() {
      g&lt;sizeof (i) / sizeof (int)&gt;();
    }

    template &lt;typename T&gt;
    int S&lt;int&gt;::i[] = { 1, 2 };
</PRE>

<P>Which <TT>g</TT> is called from <TT>S&lt;int&gt;::f()</TT>?</P>

<P>If the program is valid, then surely one would
expect <TT>g&lt;2&gt;</TT> to be called.</P>

<P>If the program is valid, does <TT>S&lt;T&gt;::i</TT> have a
non-dependent type in <TT>S&lt;T&gt;::f</TT>?  If so, is it
incomplete, or is it <TT>int[1]</TT>?  (Here, <TT>int[1]</TT> would be
surprising, since <TT>S&lt;int&gt;::i</TT> actually has
type <TT>int[2]</TT>.)</P>

<P>If the program is invalid, why?</P>

<P>For a simpler example, consider:</P>

<PRE>
    template &lt;typename T&gt;
    struct S {
      static int i[];
      const int N = sizeof (i);
    };
</PRE>

<P>This is only valid if the type of <TT>i</TT> is dependent,
meaning that the <TT>sizeof</TT> expression isn't evaluated until
the class is instantiated.</P>

<BR><BR><HR><A NAME="674"></A><H4>674.
  
&#8220;matching specialization&#8221; for a friend declaration
</H4><B>Section: </B>14.5.4&#160;
 [temp.friend]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Widman
 &#160;&#160;&#160;

 <B>Date: </B>7 February, 2008<BR>




<P>14.5.4
 [temp.friend] paragraph 1 bullet 3 says:</P>

<UL><LI><P>if the name of the friend is a <I>qualified-id</I> and a
matching specialization of a function template is found in the
specified class or namespace, the friend declaration refers to that
function template specialization, otherwise,</P></LI></UL>

<P>I'm not sure this says what it's supposed to say.  For example:</P>

<PRE>
    namespace N {
        template&lt;class T&gt; int f(T);
    }

    class A {
        friend int N::f(int);
        int m;
        A();
    };

    namespace N {
        template&lt; class T &gt; int f(T) {
            A a;            //<SPAN STYLE="font-family:Times"><I> ok for </I></SPAN>T=int<SPAN STYLE="font-family:Times"><I>?</I></SPAN>
            return a.m;     //<SPAN STYLE="font-family:Times"><I> ok for </I></SPAN>T=int<SPAN STYLE="font-family:Times"><I>?</I></SPAN>
        }
    }

    int m = N::f(42);       //<SPAN STYLE="font-family:Times"><I> ok?</I></SPAN>
    char c = N::f('a');     //<SPAN STYLE="font-family:Times"><I> Clearly ill-formed.</I></SPAN>
</PRE>

<P>The key is that the wording talks about a &#8220;matching
specialization,&#8221; which to me means that <TT>N::f&lt;int&gt;</TT> is befriended only
if that specialization existed in <TT>N</TT> before the friend declaration.  So
it's ill-formed as written, but if we move the call to <TT>N::f&lt;int&gt;</TT> up to
a point before the definition of <TT>A</TT>, it's well-formed.</P>

<P>That seems surprising, especially given that the first bullet does
not require a pre-existing specialization.  So I suggest replacing
bullet 3 with something like:</P>

<UL><LI><P>if the name of the friend is a <I>qualified-id</I> and a
matching function template is found in the specified class or
namespace, the friend declaration refers to the deduced specialization
of that function template, otherwise,</P></LI></UL>

<BR><BR><HR><A NAME="549"></A><H4>549.
  
Non-deducible parameters in partial specializations
</H4><B>Section: </B>14.5.5.1&#160;
 [temp.class.spec.match]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Martin Sebor
 &#160;&#160;&#160;

 <B>Date: </B>18 November 2005<BR>


<P>In the following example, the template parameter in the partial
specialization is non-deducible:</P>

<PRE>
    template &lt;class T&gt; struct A { typedef T U; };
    template &lt;class T&gt; struct C { };
    template &lt;class T&gt; struct C&lt;typename A&lt;T&gt;::U&gt; { };
</PRE>

<P>Several compilers issue errors for this case, but there appears
to be nothing in the Standard that would make this ill-formed; it
simply seems that the partial specialization will never be matched,
so the primary template will be used for all specializations.
Should it be ill-formed?</P>

<P><B>Notes from the April, 2006 meeting:</B></P>

<P>It was noted that there are similar issues for constructors and
conversion operators with non-deducible parameters, and that they
should probably be dealt with similarly.</P>

<BR><BR><HR><A NAME="532"></A><H4>532.
  
Member/nonmember operator template partial ordering
</H4><B>Section: </B>14.5.6.2&#160;
 [temp.func.order]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Nathan Sidwell
 &#160;&#160;&#160;

 <B>Date: </B>16 September 2005<BR>




<P>The Standard does not specify how member and nonmember function
templates are to be ordered.  This question arises with an example
like the following:</P>

<PRE>
    struct A {
        template&lt;class T&gt; void operator&lt;&lt;(T&amp;);
    };

    template&lt;class T&gt; struct B { };
    template&lt;class T&gt; void operator&lt;&lt;(A&amp;, B&lt;T&gt;&amp;);

    int main() {
        A a;
        B&lt;A&gt; b;
        a &lt;&lt; b;
    }
</PRE>

<P>The two candidates for &#8220;<TT>a &lt;&lt; b</TT>&#8221; are:</P>

<OL>

<LI><TT>A::operator&lt;&lt; &lt;B&lt;A&gt; &gt;(B&lt;A&gt;&amp;)</TT></LI>

<LI><TT>::operator&lt;&lt; &lt;A&gt;(A&amp;, B&lt;A&gt;&amp;)</TT></LI>

</OL>

<P>How should we treat the implicit <TT>this</TT> parameter of #1 and the
explicit first parameter of #2?</P>

<UL>

<P>Option 0: Make them unordered.</P>

<P>Option 1: If either function is a non-static member function, ignore
any <TT>this</TT> parameter and ignore the first parameter of any
non-member function.  This option will select #2, as
&#8220;<TT>B&lt;T&gt;&amp;</TT>&#8221; is more specialized than
&#8220;<TT>T&amp;</TT>&#8221;.</P>

<P>Option 2: Treat the <TT>this</TT> parameter as if it were of
reference to object type, and then perform comparison to the first
parameter of the other function.  The other function's first parameter
will either be another <TT>this</TT> parameter, or it will be a
by-value or by-reference object parameter.  In the example above,
this option will also select #2.</P>

</UL>

<P>The difference between option 1 and option 2 can be seen in the
following example:</P>

<PRE>
    struct A { };

    template&lt;class T&gt; struct B {
        template&lt;typename R&gt; int operator*(R&amp;);   //<SPAN STYLE="font-family:Times"><I> #1</I></SPAN>
    };

    template &lt;typename T&gt; int operator*(T&amp;, A&amp;);  //<SPAN STYLE="font-family:Times"><I> #2</I></SPAN>

    int main() {
        A a;
        B&lt;A&gt; b;
        b * a;
    }
</PRE>

<P>Should this select #1, select #2, or be ambiguous?  Option 1 will
select #2, because &#8220;<TT>A&amp;</TT>&#8221; is more specialized
than &#8220;<TT>T&amp;</TT>&#8221;.  Option 2 will make this example
ambiguous, because &#8220;<TT>B&lt;A&gt;&amp;</TT>&#8221; is more
specialized than &#8220;<TT>T&amp;</TT>&#8221;.</P>

<P>If one were considering two non-member templates,</P>

<PRE>
    template &lt;typename T&gt; int operator*(T&amp;, A&amp;);                 //<SPAN STYLE="font-family:Times"><I> #2</I></SPAN>
    template &lt;typename T, typename R&gt; int operator*(B&lt;A&gt;&amp;, R&amp;);  //<SPAN STYLE="font-family:Times"><I> #3</I></SPAN>
</PRE>

<P>the current rules would make these unordered.  Option 2 thus seems
more consistent with this existing behavior.</P>

<P><B>Notes from the April, 2006 meeting:</B></P>

<P>The group favored option 2.</P>

<BR><BR><HR><A NAME="560"></A><H4>560.
  
Use of the <TT>typename</TT> keyword in return types
</H4><B>Section: </B>14.6&#160;
 [temp.res]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Greg Comeau
 &#160;&#160;&#160;

 <B>Date: </B>11 February 2006<BR>


<P>Consider the following example:</P>

<PRE>
    template &lt;class T&gt; struct Outer {
        struct Inner {
            Inner* self();
        };
    };
    template &lt;class T&gt; Outer&lt;T&gt;::Inner*
        Outer&lt;T&gt;::Inner::self() { return this; }
</PRE>

<P>According to 14.6
 [temp.res] paragraph 3 (before the
salient wording was inadvertently removed, see
<A HREF="
     cwg_defects.html#559">issue 559</A>),</P>

<BLOCKQUOTE>

A <I>qualified-id</I> that refers to a type and in which the
<I>nested-name-specifier</I> depends on a <I>template-parameter</I>
(14.6.2
 [temp.dep]) but does not refer to a member of the
current instantiation (14.6.2.1
 [temp.dep.type]) shall be
prefixed by the keyword <TT>typename</TT> to indicate that
the <I>qualified-id</I> denotes a type, forming
a <I>typename-specifier</I>.

</BLOCKQUOTE>

<P>Because <TT>Outer&lt;T&gt;::Inner</TT> is a member of the current
instantiation, the Standard does not currently require that it be
prefixed with <TT>typename</TT> when it is used in the return type of
the definition of the <TT>self()</TT> member function.  However, it is
difficult to parse this definition correctly without knowing that the
return type is, in fact, a type, which is what the <TT>typename</TT>
keyword is for.  Should the Standard be changed to require
<TT>typename</TT> in such contexts?</P>

<BR><BR><HR><A NAME="448"></A><H4>448.
  
Set of template functions in call with dependent explicit argument
</H4><B>Section: </B>14.6.1&#160;
 [temp.local]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mark Mitchell
 &#160;&#160;&#160;

 <B>Date: </B>4 Jan 2004<BR>


<P>Is this program valid?</P>
<PRE>
  template &lt;typename T&gt; int g(int);
  class h{};
  template &lt;typename T&gt; int l(){h j; return g&lt;T&gt;(j);}
  template &lt;typename T&gt; int g(const h&amp;);
  class j{};
  int jj(){return l&lt;j&gt;();}
</PRE>
<P>The key issue is when "g" is looked up, i.e., whether both overloaded
template "g" functions are available at the call site or only the
first.  Clearly, the entire postfix-expression "g&lt;T&gt;(j)" is dependent,
but when is the set of available template functions determined?</P>

<P>For consistency with the rules about when the set of available
overloads is determined when calling a function given by an
unqualified-id, I would think that we should postpone determining the
set of template functions if (and only if) any of the explicit
template arguments are dependent.</P>

<P><U>John Spicer:</U>
I agree that there should be a core issue for this.  The definition of 
"dependent name" (14.6.2
 [temp.dep] paragraph 1)
should probably be modified to cover this case.  It 
currently only handles cases where the function name is a simple
identifier.</P>

<P><B>Notes from the March 2004 meeting:</B></P>

<P>A related issue is a call with a qualified name and dependent
arguments, e.g., <TT>x::y(depa, depb)</TT>.</P>

<BR><BR><HR><A NAME="458"></A><H4>458.
  
Hiding of member template parameters by other members
</H4><B>Section: </B>14.6.1&#160;
 [temp.local]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Gabriel Dos Reis
 &#160;&#160;&#160;

 <B>Date: </B>2 Feb 2004<BR>




<P>The list of cases in 14.6.1
 [temp.local]
about when a template parameter is hidden
seems to be incomplete.</P>

<P>Consider</P>
<PRE>
      // example-1
    struct S {
       int C;
       template&lt;class&gt; void f();
    };

    template&lt;class C&gt;
      void S::f()
      {
         C c;           // #1
      }
</PRE>
<P>Someone asked whether line #1 is well-formed and I responded "no"
based on my understanding of the rules in 14.6.1.
After a second looking, I've realized that the above case is currently
missing from the list.</P>

<P>The list in 14.6.1 covers cases like
<PRE>
     // example-2
   template&lt;class T&gt;
     struct S {
        int C;
        void f();
     };

   template&lt;class C&gt;
     void S&lt;C&gt;::f()
     {
       C c;     // ERROR: 'C' is 'S::C' not the template parameter
     }
</PRE>
or
<PRE>
     // example-3
   struct A { int C; }

   template&lt;class C&gt;
      struct S : A {
        C c;    // ERROR: 'C' is 'A::C', not the template parameter
      };
</PRE>
But the case of a 'member template' is missing.  I believe it should
follow the same rule as above.  The reason is this.</P>

<P>In the case listed in 14.6.1 (having to do with members of classes),
the "algorithm" seems to be this:
<OL>
<LI>
put the "template parameter scope"[1] on the top of active
       scope stack.  That will make the template parameter
       declarations the innermost bindings.
</LI>
<LI>
Enter the class scope. That will push more scopes on the stack.
       In particular, any bindings from non-dependent base classes or
       from the class definition will hide any previous bindings,
       especially the template parameter declarations.
</LI>
</OL>
The above formulation uniformly covers paragraphs 5 and 7 of section
14.6.1 and gives a general view of how name lookup is supposed to 
happen.</P>

<P>I believe that any rule, coherent with 14.6.1/5 and 14.6.1/7, for
covering the  cases of member templates (example-1) will be described
by the above "algorithm".</P>

<P>Am I missing something?</P>

<P>[1] of course, the standard text does not formally speak of "template
    parameter scope", but we all know that the template parameters
    "live" somewhere.  I'm using that terminology to designate the
    declarative region of the template parameters.</P>

<P><U>Mike Miller:</U>
I have a somewhat different perspective on this question.  I
think your example-1 is fundamentally different from your
example-2 and example-3.  Looking, for instance, at your
example-2, I see four nested scopes:</P>
<PRE>
     namespace scope
       template scope (where the parameter is)
         class S scope
           S::f() block scope
</PRE>
<P>Naturally, S::C hides the template parameter C.  The same is
true of your example-3, with three scopes:</P>
<PRE>
     namespace scope
       template scope
         class S scope (includes 10.2 base class lookup)
</PRE>
<P>Again, it's clear that the C inherited from A hides the template
parameter in the containing scope.</P>

<P>The scopes I see in your example-1, however, are different:</P>
<PRE>
     namespace scope
       struct S scope
         template scope (where the parameter is)
           S::f() block scope
</PRE>
<P>Here it seems clear to me that the template parameter hides the
class member.</P>

<P>It might help to look at the case where the function template is
defined inline in the class:</P>
<PRE>
     struct S {
        int C;
        template&lt;class C&gt; int f() {
            C c;   // #1
        }
     };
</PRE>
<P>It would be pretty strange, I think, if the #1 C were the member
and not the template parameter.  It would also be odd if the
name lookup were different between an inline definition and an
out-of-line definition.</P>

<P>See also <A HREF="
     cwg_active.html#459">issue 459</A>.</P>

<P><B>Notes from the March 2004 meeting:</B></P>

<P>Basically, the standard is okay.  We think Gaby's desired
cases like #1 should be ill-formed.</P>

<P> There is a wording problem in 14.6.1
 [temp.local] paragraph 7.
It says:</P>
<BLOCKQUOTE>
In the definition of a member of a class template that appears outside of the 
class template definition, the name of a member of this template hides
the name of a template-parameter.
</BLOCKQUOTE>

<P>It should say "hides the name of a template-parameter of the class template 
(but not a template-parameter of the member, if the member is itself a 
template)" or words to that effect.</P>

<BR><BR><HR><A NAME="541"></A><H4>541.
  
Dependent function types
</H4><B>Section: </B>14.6.2.2&#160;
 [temp.dep.expr]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>22 October 2005<BR>


<P>14.6.2.2
 [temp.dep.expr] paragraph 3 says,</P>

<BLOCKQUOTE>

An <I>id-expression</I> is type-dependent if it contains:

<UL><LI>an identifier that was declared with a dependent type...</LI></UL>

</BLOCKQUOTE>

<P>This treatment seems inadequate with regard to
<I>id-expression</I>s in function calls:</P>

<OL>

<LI><P>According to 14.6.2.1
 [temp.dep.type] paragraph 6,</P>

<BLOCKQUOTE>

A type is dependent if it is

<UL>

<LI>...</LI>

<LI>a compound type constructed from any dependent type...</LI>

</UL>

</BLOCKQUOTE>

<P>This would apply to the type of a member function of a class
template if any of its parameters are dependent, even if the return
type is not dependent.  However, there is no need for a call to such a
function to be a type-dependent expression because the type of the
expression is known at definition time.</P>

</LI>

<LI><P>This wording does not handle the case of overloaded functions,
some of which might have dependent types (however defined) and others
not.</P>

</LI>

</OL>

<BR><BR><HR><A NAME="2"></A><H4>2.
  
How can dependent names be used in member declarations that appear outside of the class template definition?
</H4><B>Section: </B>14.6.4&#160;
 [temp.dep.res]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>unknown
 &#160;&#160;&#160;

 <B>Date: </B>unknown<BR>





<PRE>
    template &lt;class T&gt; class Foo {
    
       public:
       typedef int Bar;
       Bar f();
    };
    template &lt;class T&gt; typename Foo&lt;T&gt;::Bar Foo&lt;T&gt;::f() { return 1;}
                       --------------------
</PRE>
In the class template definition, the declaration of the member function
is interpreted as:
<PRE>
   int Foo&lt;T&gt;::f();
</PRE>
In the definition of the member function that appears outside of the class
template, the return type is not known until the member function
is instantiated.
Must the return type of the member function be known when this out-of-line
definition is seen (in which case the definition above is ill-formed)?
Or is it OK to wait until the member function is instantiated to see if
the type of the return type matches the return type in the class template
definition (in which case the definition above is well-formed)?
    
<P><B>Suggested resolution:</B> (John Spicer)</P>
    
<P>My opinion (which I think matches several posted on the reflector recently)
is that the out-of-class definition must match the
declaration in the template. 
In your example they do match, so it is well formed.</P>
    
<P>I've added some additional cases that illustrate cases that I think
either are allowed or should be allowed, and some cases that I don't think
are allowed.</P>
<PRE>
    template &lt;class T&gt; class A { typedef int X; };
    
    
    template &lt;class T&gt; class Foo {
     public:
       typedef int Bar;
       typedef typename A&lt;T&gt;::X X;
       Bar f();
       Bar g1();
       int g2();
       X h();
       X i();
       int j();
     };
    
     // Declarations that are okay
     template &lt;class T&gt; typename Foo&lt;T&gt;::Bar Foo&lt;T&gt;::f()
                                                     { return 1;}
     template &lt;class T&gt; typename Foo&lt;T&gt;::Bar Foo&lt;T&gt;::g1()
                                                     { return 1;}
     template &lt;class T&gt; int Foo&lt;T&gt;::g2() { return 1;}
     template &lt;class T&gt; typename Foo&lt;T&gt;::X Foo&lt;T&gt;::h() { return 1;}
    
     // Declarations that are not okay
     template &lt;class T&gt; int Foo&lt;T&gt;::i() { return 1;}
     template &lt;class T&gt; typename Foo&lt;T&gt;::X Foo&lt;T&gt;::j() { return 1;}
</PRE>
In general, if you can match the declarations up using only information
from the template, then the declaration is valid.

<P>Declarations like <TT>Foo::i</TT> and <TT>Foo::j </TT>are invalid because
for a given instance of <TT>A&lt;T&gt;</TT>, <TT>A&lt;T&gt;::X</TT> may not actually
be int if the class is specialized.</P>

<P>This is not a problem for <TT>Foo::g1</TT> and <TT>Foo::g2</TT> because
for any instance of <TT>Foo&lt;T&gt;</TT> that is generated from the template
you know that Bar will always be int. If an instance of <TT>Foo</TT> is
specialized, the template member definitions are not used so it doesn't
matter whether a specialization defines <TT>Bar</TT> as int or not.</P>


<BR><BR><HR><A NAME="287"></A><H4>287.
  
Order dependencies in template instantiation
</H4><B>Section: </B>14.6.4.1&#160;
 [temp.point]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Martin Sebor
 &#160;&#160;&#160;

 <B>Date: </B>17 May 2001<BR>




<P>Implementations differ in their treatment of the following
code:</P>

<PRE>
    template &lt;class T&gt;
    struct A {
	typename T::X x;
    };

    template &lt;class T&gt;
    struct B {
	typedef T* X;
	A&lt;B&gt; a;
    };

    int main ()
    {
	B&lt;int&gt; b;
    }
</PRE>

<P>Some implementations accept it.  At least one rejects it
because the instantiation of <TT>A&lt;B&lt;int&gt; &gt;</TT>
requires that <TT>B&lt;int&gt;</TT> be complete, and it is
not at the point at which <TT>A&lt;B&lt;int&gt; &gt;</TT>
is being instantiated.</P>

<P><U>Erwin Unruh</U>:</P>

<P>In my view the programm is ill-formed. My reasoning:</P>

<UL>

<LI>you need a complete type <TT>B&lt;int&gt;</TT> because you declare
a variable in <TT>main</TT></LI>

<LI><TT>B&lt;int&gt;</TT> contains a member of type
<TT>A&lt;B&lt;int&gt; &gt;</TT>, so you need that complete.</LI>

<LI><TT>A&lt;B&lt;int&gt; &gt;</TT> tries to access
<TT>B&lt;int&gt;::X</TT>, which in turn needs <TT>B&lt;int&gt;</TT>
being complete.</LI>

</UL>

<P>So each class needs the other to be complete.</P>

<P>The problem can be seen much easier if you replace the typedef with</P>
<PRE>
    typedef T (*X) [sizeof(B::a)];
</PRE>

<P>Now you have a true recursion. The compiler cannot easily distinguish
between a true recursion and a potential recursion.</P>

<P><U>John Spicer</U>:</P>

<P>Using a class to form a qualified name does not require the class to be
complete, it only requires that the named member already have been declared.
In other words, this kind of usage is permitted:</P>

<PRE>
    class A {
        typedef int B;
        A::B ab;
    };
</PRE>

<P>In the same way, once <TT>B</TT> has been declared in <TT>A</TT>,
it is also visible to any template that uses <TT>A</TT> through a
template parameter.</P>

<P>The standard could be more clear in this regard, but there are two
notes that make this point.  Both 3.4.3.1
 [class.qual] and
5.1
 [expr.prim] paragraph 7 contain a note that says "a
class member can be referred to using a qualified-id at any point in
its potential scope (3.3.6
 [basic.scope.class])."  A member's
potential scope begins at its point of declaration.</P>

<P>In other words, a class has three states: incomplete, being
completed, and complete.  The standard permits a qualified name to be
used once a name has been declared.  The quotation of the notes about
the potential scope was intended to support that.</P>

<P>So, in the original example, class <TT>A</TT> does not require the
type of <TT>T</TT> to be complete, only that it have already declared
a member <TT>X</TT>.</P>

<P><U>Bill Gibbons</U>:</P>

<P>The template and non-template cases are different.  In the non-template
case the order in which the members become declared is clear.  In the
template case the members of the instantiation are conceptually all
created at the same time.  The standard does not say anything about
trying to mimic the non-template case during the instantiation of a class
template.</P>

<P><U>Mike Miller</U>:</P>

<P>I think the relevant specification is 14.6.4.1
 [temp.point] paragraph 3, dealing with the point of
instantiation:</P>

<BLOCKQUOTE>

For a class template specialization... if the specialization is
implicitly instantiated because it is referenced from within
another template specialization, if the context from which the
specialization is referenced depends on a template parameter, and
if the specialization is not instantiated previous to the
instantiation of the enclosing template, the point of
instantiation is immediately before the point of instantiation
of the enclosing template.  Otherwise, the point of instantiation
for such a specialization immediately precedes the namespace scope
declaration or definition that refers to the specialization.

</BLOCKQUOTE>

<P>That means that the point of instantiation of <TT>A&lt;B&lt;int&gt;
&gt;</TT> is before that of <TT>B&lt;int&gt;</TT>, not in the middle
of <TT>B&lt;int&gt;</TT> after the declaration of <TT>B::X</TT>, and
consequently a reference to <TT>B&lt;int&gt;::X</TT> from
<TT>A&lt;B&lt;int&gt; &gt;</TT> is ill-formed.</P>

<P>To put it another way, I believe John's approach requires that there
be an instantiation stack, with the results of partially-instantiated
templates on the stack being available to instantiations above them.
I don't think the Standard mandates that approach; as far as I can
see, simply determining the implicit instantiations that need to be
done, rewriting the definitions at their respective points of
instantiation with parameters substituted (with appropriate "forward
declarations" to allow for non-instantiating references), and
compiling the result normally should be an acceptable implementation
technique as well.  That is, the implicit instantiation of the
example (using, e.g., <TT>B_int</TT> to represent the generated name of the
<TT>B&lt;int&gt;</TT> specialization) could be something like</P>

<PRE>
        struct B_int;

        struct A_B_int {
            B_int::X x;    // error, incomplete type
        };

        struct B_int {
            typedef int* X;
            A_B_int a;
        };
</PRE>

<P><B>Notes from 10/01 meeting:</B></P>

<P>This was discussed at length.  The consensus was that the template case
should be treated the same as the non-template class case it terms of
the order in which members get declared/defined and classes get completed.</P>

<P><B>Proposed resolution:</B></P>

<P>
In 14.6.4.1
 [temp.point] paragraph 3 change:</P>
<BLOCKQUOTE>
the point of instantiation is immediately before the point of
instantiation of the enclosing template. Otherwise, the point of
instantiation for such a specialization immediately precedes the
namespace scope declaration or definition that refers to the
specialization.
</BLOCKQUOTE>
<P> To:</P>
<BLOCKQUOTE>
the point of instantiation is <B>the same as</B> the point of
instantiation of the enclosing template. Otherwise, the point of
instantiation for such a specialization immediately precedes the
<B>nearest enclosing declaration</B>.
<B>[Note: The point of instantiation is still at namespace scope but
any declarations preceding the point of instantiation, even if not
at namespace scope, are considered to have been seen.]</B>
</BLOCKQUOTE>

<P> Add following paragraph 3:</P>
<BLOCKQUOTE>
If an implicitly instantiated class template specialization, class
member specialization, or specialization of a class template references
a class, class template specialization, class member specialization, or
specialization of a class template containing a specialization reference
that directly or indirectly caused the instantiation, the requirements
of completeness and ordering of the class reference are applied in the
context of the specialization reference.
</BLOCKQUOTE>

<P>and the following example</P>

<PRE>
  template &lt;class T&gt; struct A {
          typename T::X x;
  };

  struct B {
          typedef int X;
          A&lt;B&gt; a;
  };

  template &lt;class T&gt; struct C {
          typedef T* X;
          A&lt;C&gt; a;
  };

  int main ()
  {
          C&lt;int&gt; c;
  }
</PRE>

<P><B>Notes from the October 2002 meeting:</B></P>

<P>This needs work.  Moved back to drafting status.</P>

<BR><BR><HR><A NAME="561"></A><H4>561.
  
Internal linkage functions in dependent name lookup
</H4><B>Section: </B>14.6.4.2&#160;
 [temp.dep.candidate]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Joaqu&#237;n L&#243;pez Mu&#241;oz
 &#160;&#160;&#160;

 <B>Date: </B>17 February 2006<BR>


<P>According to 14.6.4.2
 [temp.dep.candidate],</P>

<BLOCKQUOTE>

<P>For a function call that depends on a template parameter, if the
function name is an <I>unqualified-id</I> but not
a <I>template-id</I>, the candidate functions are found using the
usual lookup rules (3.4.1
 [basic.lookup.unqual], 3.4.2
 [basic.lookup.argdep]) except that:</P>

<UL>
<LI><P>For the part of the lookup using unqualified name lookup
(3.4.1
 [basic.lookup.unqual]), only function declarations with
external linkage from the template definition context are
found.</P></LI>

<LI><P>For the part of the lookup using associated namespaces
(3.4.2
 [basic.lookup.argdep]), only function declarations with
external linkage found in either the template definition context or
the template instantiation context are found.</P></LI>
</UL>

</BLOCKQUOTE>

<P>It is not at all clear why a call using a <I>template-id</I>
would be treated differently from one not using a <I>template-id</I>.
Furthermore, is it really necessary to exclude internal linkage
functions from the lookup?  Doesn't the ODR give implementations
sufficient latitude to handle this case without another wrinkle
on name lookup?</P>

<P>(See also <A HREF="
     cwg_defects.html#524">issue 524</A>.)</P>

<P><B>Notes from the April, 2006 meeting:</B></P>

<P>The consensus of the group was that <I>template-id</I>s should not
be treated differently from <I>unqualified-id</I>s (although it's not
clear how argument-dependent lookup works for <I>template-id</I>s),
and that internal-linkage functions should be found by the lookup
(although they may result in errors if selected by overload
resolution).</P>

<P><B>Note (June, 2006):</B></P>

<P>Although the notes from the Berlin meeting indicate that
argument-dependent lookup for <I>template-id</I>s is under-specified
in the Standard, further examination indicates that that is not the
case: the note in 14.8.1
 [temp.arg.explicit] paragraph 8 clearly
indicates that argument-dependent lookup is to be performed for
<I>template-id</I>s, and 3.4.2
 [basic.lookup.argdep] paragraph 4
describes the lookup performed:</P>

<BLOCKQUOTE>

When considering an associated namespace, the lookup is the same as
the lookup performed when the associated namespace is used as a
qualifier (3.4.3.2
 [namespace.qual]) except that:

<UL>

<LI><P>Any <I>using-directive</I>s in the associated namespace are
ignored.</P></LI>

<LI><P>Any namespace-scope friend functions declared in associated
classes are visible within their respective namespaces even if they
are not visible during an ordinary lookup (11.4
 [class.friend]).</P></LI>

</UL>

</BLOCKQUOTE>

<BR><BR><HR><A NAME="212"></A><H4>212.
  
Implicit instantiation is not described clearly enough
</H4><B>Section: </B>14.7.1&#160;
 [temp.inst]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Christophe de Dinechin
 &#160;&#160;&#160;

 <B>Date: </B>7 Mar 2000<BR>




<P>Three points have been raised where the wording in
14.7.1
 [temp.inst] may not be sufficiently clear.</P>

<OL>

<LI>

In paragraph 4, the statement is made that

<BLOCKQUOTE>

A class template specialization is implicitly instantiated...  if the
completeness of the class type affects the semantics of the program...

</BLOCKQUOTE>

<P>It is not clear what it means for the "completeness... [to affect]
the semantics."  Consider the following example:</P>

<PRE>
        template&lt;class T&gt; struct A;
        extern A&lt;int&gt; a;

        void *foo() { return &amp;a; }

        template&lt;class T&gt; struct A
        {
        #ifdef OPTION
                void *operator &amp;() { return 0; }
        #endif
        };
</PRE>

<P>The question here is whether it is necessary for template class
<TT>A</TT> to declare an <TT>operator &amp;</TT> for the semantics of the
program to be affected.  If it does not do so, the meaning of
<TT>&amp;a</TT> will be the same whether the class is complete or
not and thus arguably the semantics of the program are not
affected.</P>

<P>Presumably what was intended is whether the presence or absence of
certain member declarations in the template class might be relevant in
determining the meaning of the program.  A clearer statement may be
desirable.</P>

</LI>

<LI>

Paragraph 5 says,

<BLOCKQUOTE>

If the overload resolution process can determine the correct function
to call without instantiating a class template definition, it is
unspecified whether that instantiation actually takes place.

</BLOCKQUOTE>

<P>The intent of this wording, as illustrated in the example in that
paragraph, is to allow a "smart" implementation not to instantiate
class templates if it can determine that such an instantiation will
not affect the result of overload resolution, even though the
algorithm described in clause 13
 [over] requires that
all the viable functions be enumerated, including functions that might
be found as members of specializations.</P>

<P>Unfortunately, the looseness of the wording allowing this latitude
for implementations makes it unclear what "the overload resolution
process" is &#8212; is it the algorithm in 13
 [over] or
something else? &#8212; and what "the correct function" is.</P>

</LI>

<LI>

According to paragraph 6,

<BLOCKQUOTE>

If an implicit instantiation of a class template specialization is
required and the template is declared but not defined, the program is
ill-formed.

</BLOCKQUOTE>

<P>Here, it is not clear what conditions "require" an implicit
instantiation.  From the context, it would appear that the intent is
to refer to the conditions in paragraph 4 that cause a specialization
to be instantiated.</P>

<P>This interpretation, however, leads to different treatment of
template and non-template incomplete classes.  For example, by this
interpretation,</P>

<PRE>
    class A;
    template &lt;class T&gt; struct TA;
    extern A a;
    extern TA&lt;int&gt; ta;

    void f(A*);
    void f(TA&lt;int&gt;*);

    int main()
    {
        f(&amp;a);    // well-formed; undefined if A
                  // has operator &amp;() member
        f(&amp;ta);   // ill-formed: cannot instantiate
    }
</PRE>

<P>A different approach would be to understand "required" in paragraph
6 to mean that a complete type is required in the expression.  In this
interpretation, if an incomplete type is acceptable in the context and
the class template definition is not visible, the instantiation is not
attempted and the program is well-formed.</P>

<P>The meaning of "required" in paragraph 6 must be clarified.</P>

</LI>

</OL>

<P>(See also issues <A HREF="
     cwg_defects.html#204">204</A> and
<A HREF="
     cwg_defects.html#63">63</A>.)</P>

<P><B>Notes on 10/01 meeting:</B></P>

<P>It was felt that item 1 is solved by addition of the word "might"
in the resolution for <A HREF="
     cwg_defects.html#63">issue 63</A>; item 2
is not much of a problem; and item 3 could be solved by changing
"required" to "required to be complete".</P>

<BR><BR><HR><A NAME="546"></A><H4>546.
  
Explicit instantiation of class template members
</H4><B>Section: </B>14.7.2&#160;
 [temp.explicit]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Martin Sebor
 &#160;&#160;&#160;

 <B>Date: </B>29 October 2005<BR>


<P><A HREF="
     cwg_defects.html#470">Issue 470</A> specified the explicit
instantiation of members of explicitly-instantiated class templates.
In restricting the affected members to those &#8220;whose definition
is visible at the point of instantiation,&#8221; however, this
resolution introduced an incompatibility between explicitly
instantiating a member function or static data member and explicitly
instantiating the class template of which it is a member (14.7.2
 [temp.explicit] paragraph 3 requires only that the class template
definition, not that of the member function or static data member, be
visible at the point of the explicit instantiation).  It would be
better to treat the member instantiations the same, regardless of
whether they are directly or indirectly explicitly instantiated.</P>

<P><B>Notes from the April, 2006 meeting:</B></P>

<P>In forwarding document J16/06-0057 = WG21 N1987 to be approved by
the full Committee, the CWG reaffirmed its position that explicitly
instantiating a class template only explicitly instantiates those of
its members that have been defined before the point of the explicit
instantiation.  The effect of the position advocated above would be to
require all non-exported member functions to be defined in the
translation unit in which the class template is explicitly
instantiated (cf paragraph 4), and we did not want to require that.
We did agree that the &#8220;visible&#8221; terminology should be
replaced by wording along the lines of &#8220;has been
defined.&#8221;</P>

<BR><BR><HR><A NAME="529"></A><H4>529.
  
Use of <TT>template&lt;&gt;</TT> with &#8220;explicitly-specialized&#8221; class templates
</H4><B>Section: </B>14.7.3&#160;
 [temp.expl.spec]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Widman
 &#160;&#160;&#160;

 <B>Date: </B>16 August 2005<BR>


<P>Paragraph 17 of 14.7.3
 [temp.expl.spec] says,</P>

<BLOCKQUOTE>

A member or a member template may be nested within many enclosing
class templates. In an explicit specialization for such a member, the
member declaration shall be preceded by a <TT>template&lt;&gt;</TT>
for each enclosing class template that is explicitly specialized.

</BLOCKQUOTE>

<P>This is curious, because paragraph 3 only allows explicit
specialization of members of implicitly-instantiated class
specializations, not explicit specializations.  Furthermore,
paragraph 4 says,</P>

<BLOCKQUOTE>

Definitions of members of an explicitly specialized class are defined
in the same manner as members of normal classes, and not using the
explicit specialization syntax.

</BLOCKQUOTE>

<P>Paragraph 18 provides a clue for resolving the apparent
contradiction:</P>

<BLOCKQUOTE>

In an explicit specialization declaration for a member of a class
template or a member template that appears in namespace scope, the
member template and some of its enclosing class templates may remain
unspecialized, except that the declaration shall not explicitly
specialize a class member template if its enclosing class templates
are not explicitly specialized as well. In such explicit
specialization declaration, the keyword <TT>template</TT> followed by
a <I>template-parameter-list</I> shall be provided instead of
the <TT>template&lt;&gt;</TT> preceding the explicit specialization
declaration of the member.

</BLOCKQUOTE>

<P>It appears from this and the following example that the phrase
&#8220;explicitly specialized&#8221; in paragraphs 17 and 18, when
referring to enclosing class templates, does not mean that explicit
specializations have been declared for them but that their names in
the <I>qualified-id</I> are followed by template argument lists.  This
terminology is confusing and should be changed.</P>

<P><B>Proposed resolution (October, 2005):</B></P>

<OL><LI><P>Change 14.7.3
 [temp.expl.spec] paragraph 17 as
indicated:</P></LI>

<BLOCKQUOTE>

A member or a member template may be nested within many enclosing
class templates. In an explicit specialization for such a member, the
member declaration shall be preceded by a <TT>template&lt;&gt;</TT>
for each enclosing class template <S>that is explicitly specialized</S>
<B>specialization</B>. [<I>Example:</I>...

</BLOCKQUOTE>

<LI><P>Change 14.7.3
 [temp.expl.spec] paragraph 18 as
indicated:</P></LI>

<BLOCKQUOTE>

In an explicit specialization declaration for a member of a class
template or a member template that appears in namespace scope, the
member template and some of its enclosing class templates may remain
unspecialized, <S>except that the declaration shall not explicitly
specialize a class member template if its enclosing class templates
are not explicitly specialized as well</S> <B>that is, the
<I>template-id</I> naming the template may be composed of template
parameter names rather than <I>template-argument</I>s</B>. <S>In</S>
<B>For each unspecialized template in</B> such <B>an</B> explicit
specialization declaration, the keyword <TT>template</TT> followed by
a <I>template-parameter-list</I> shall be provided instead of
the <TT>template&lt;&gt;</TT> preceding the <S>explicit
specialization</S> declaration of the member. The types of
the <I>template-parameter</I>s in the <I>template-parameter-list</I>
shall be the same as those specified in the primary template
definition. <B>In such declarations, an unspecialized <I>template-id</I>
shall not precede the name of a template specialization in the
<I>qualified-id</I> naming the member.</B> [<I>Example:</I>...

</BLOCKQUOTE>

</OL>

<P><B>Notes from the April, 2006 meeting:</B></P>

<P>The revised wording describing &#8220;unspecialized&#8221; templates
needs more work to ensure that the parameter names in the
<I>template-id</I> are in the correct order; the distinction between
template argyments and parameters is also probably not clear enough.  It
might be better to replace this paragraph completely and avoid the
&#8220;unspecialized&#8221; wording altogether.</P>

<BR><BR><HR><A NAME="531"></A><H4>531.
  
Defining members of explicit specializations
</H4><B>Section: </B>14.7.3&#160;
 [temp.expl.spec]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>1 October 2005<BR>


<P>The Standard does not fully describe the syntax to be used when a
member of an explicitly-specialized member class or member class
template is defined in namespace scope.  14.7.3
 [temp.expl.spec]
paragraph 4 says that the &#8220;explicit specialization syntax&#8221;
(presumably referring to &#8220;<TT>template&lt;&gt;</TT>&#8221;) is
not used in defining a member of an explicit specialization when a
class template is explicitly specialized as a class.  However, nothing
is said anywhere about how to define a member of a specialization
when:</P>

<OL><LI><P>the entity being specialized is a class (member of a
template class) rather than a class template.</P></LI>

<LI><P>the result of the specialization is a class template rather
than a class (cf 14.7.3
 [temp.expl.spec] paragraph 18, which
describes this case as a &#8220;member template that...
remain[s] unspecialized&#8221;).</P></LI>
</OL>

<P>(See paper J16/05-0148 = WG21 N1888 for further details, including
a survey of existing implementation practice.)</P>

<P><B>Notes from the October, 2005 meeting:</B></P>

<P>The CWG felt that the best approach, balancing consistency with
implementation issues and existing practice, would be to require that
<TT>template&lt;&gt;</TT> be used when defining members of all
explicit specializations, including those currently covered by
14.7.3
 [temp.expl.spec] paragraph 4.</P>

<BR><BR><HR><A NAME="605"></A><H4>605.
  
Linkage of explicit specializations
</H4><B>Section: </B>14.7.3&#160;
 [temp.expl.spec]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Clamage
 &#160;&#160;&#160;

 <B>Date: </B>30 November 2006<BR>




<P>Given</P>

<PRE>
    template &lt;class T&gt; static T f(T   t) { ... }
    template &lt;&gt;             int f(int t) { ... }
</PRE>

<P>what is the linkage of <TT>f(int)</TT>?</P>

<P>Section 14
 [temp] paragraph 4 says,</P>

<BLOCKQUOTE>

Entities generated from a template with internal linkage are
distinct from all entities generated in other translation units.

</BLOCKQUOTE>

<P>But is the explicit specialization &#8220;generated
from&#8221; the primary template?  Does it inherit the local
linkage?  If so, where do I find a reference saying so
explicitly?</P>

<P><U>James Widman</U>: Data points: EDG 3.8 inherits, GCC 4.0
does not.</P>

<P><U>Mike Miller</U>: There's a pretty strong presumption that
the linkage of an explicit specialization cannot be different
from that of its primary template, given that storage class
specifiers cannot appear in an explicit specialization
(7.1.1
 [dcl.stc] paragraph 1).</P>

<P><B>Notes from the April, 2007 meeting:</B></P>

<P>The CWG agreed that the linkage of an explicit specialization
must be that of the template.  Gabriel dos Reis will investigate
the reason for the different behavior of g++.</P>

<BR><BR><HR><A NAME="621"></A><H4>621.
  
Template argument deduction from function return types
</H4><B>Section: </B>14.7.3&#160;
 [temp.expl.spec]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Richard Corden
 &#160;&#160;&#160;

 <B>Date: </B>16 February 2007<BR>




<P>It does not appear that the following example is well-formed,
although most compilers accept it:</P>

<PRE>
    template &lt;typename T&gt; T foo();
    template &lt;&gt; int foo();
</PRE>

<P>The reason is that 14.7.3
 [temp.expl.spec] paragraph 11 only
allows trailing <I>template-argument</I>s to be omitted if they
&#8220;can be deduced from the function argument type,&#8221; and
there are no function arguments in this example.</P>

<P>14.7.3
 [temp.expl.spec] should probably say &#8220;function
type&#8221; instead of &#8220;function argument type.&#8221;  Also,
a subsection should probably be added to 14.8.2
 [temp.deduct]
to cover &#8220;Deducing template arguments from declarative
contexts&#8221; or some such.  It would be essentially the same as
14.8.2.2
 [temp.deduct.funcaddr] except that the function type from
the declaration would be used as the type of <TT>P</TT>.</P>

<P><B>Proposed resolution (March, 2008):</B></P>

<OL>
<LI><P>Insert the following as a new subsection after
14.8.2.5
 [temp.deduct.type]:</P></LI>

<BLOCKQUOTE>

<P><TABLE><TR>
<TD><B>14.8.2.6 Deducing template arguments in a declaration
that names a specialization of a function template</B></TD>
<TD ALIGN="right"><B>[temp.deduct.funcdecl]</B></TD>
</TR></TABLE></P>

<P>Template arguments can be deduced from the function type
specified when declaring a specialization of a function
template. [<I>Note:</I> this can occur in the context of an
explicit specialization, an explicit instantiation, or a
friend declaration. &#8212;<I>end note</I>] The function
template's function type and the declared type are used as
the types of <TT>P</TT> and <TT>A</TT>, and the deduction is
done as described in 14.8.2.5
 [temp.deduct.type].</P>

</BLOCKQUOTE>

<LI><P>Change 14.7.3
 [temp.expl.spec] paragraph 11 as
follows:</P></LI>

<BLOCKQUOTE>

A trailing <I>template-argument</I> can be left unspecified in the
<I>template-id</I> naming an explicit function template specialization
provided it can be deduced from the function <S>argument</S> type
<B>(14.8.2.6 [temp.deduct.funcdecl])</B>...

</BLOCKQUOTE>

</OL>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>The proposed resolution is probably more than is needed.
Instead of a complete new section, the material could become a
paragraph in 14.5.6
 [temp.fct].</P>

<BR><BR><HR><A NAME="575"></A><H4>575.
  
Criteria for deduction failure
</H4><B>Section: </B>14.8.2&#160;
 [temp.deduct]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Widman
 &#160;&#160;&#160;

 <B>Date: </B>19 April 2006<BR>




<P>The last two sentences of 14.8.2
 [temp.deduct] paragraph 5
read:</P>

<BLOCKQUOTE>

When all template arguments have been deduced or obtained from default
template arguments, all uses of template parameters in non-deduced
contexts are replaced with the corresponding deduced or default
argument values. If the substitution results in an invalid type, as
described above, type deduction fails.

</BLOCKQUOTE>

<P>Shouldn't the substitution occur for all uses of the parameters, so
that any of them could result in deduction failure?</P>

<P><B>Proposed resolution (October, 2006):</B></P>

<P>Change 14.8.2
 [temp.deduct] paragraph 5 as follows:</P>

<BLOCKQUOTE>

...When all template arguments have been deduced or obtained from
default template arguments, all uses of template parameters in
<S>non-deduced contexts</S> <B>the function type</B> are replaced with
the corresponding deduced or default argument values. If the
substitution results in an invalid type, as described above, type
deduction fails.

</BLOCKQUOTE>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>This issue was returned to "drafting" status in order to
coordinate the wording with the concepts proposal.</P>

<BR><BR><HR><A NAME="709"></A><H4>709.
  
Enumeration names as <I>nested-name-specifier</I>s in deduction failure
</H4><B>Section: </B>14.8.2&#160;
 [temp.deduct]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Doug Gregor
 &#160;&#160;&#160;

 <B>Date: </B>23 Aug, 2008<BR>




<P>The current rules in 14.8.2
 [temp.deduct] say that type
deduction fails as a result of attempting to use a type that is
not a class type in a qualified name.  However, it is now possible
to use enumeration names as <I>nested-name-specifier</I>s, so this
rule needs to be updated accordingly.</P>

<BR><BR><HR><A NAME="493"></A><H4>493.
  
Type deduction from a <TT>bool</TT> context
</H4><B>Section: </B>14.8.2.3&#160;
 [temp.deduct.conv]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>17 Dec 2004<BR>


<P>An expression used in an <TT>if</TT> statement is implicitly
converted to type <TT>bool</TT> (6.4
 [stmt.select]).
According to the rules of template argument deduction for
conversion functions given in 14.8.2.3
 [temp.deduct.conv],
the following example is ill-formed:</P>

<PRE>
    struct X {
      template&lt;class T&gt; operator const T&amp;() const;
    };
    int main()
    {
      if( X() ) {}
    }
</PRE>

<P>Following the logic in 14.8.2.3
 [temp.deduct.conv],
<TT>A</TT> is <TT>bool</TT> and <TT>P</TT> is <TT>const T</TT>
(because cv-qualification is dropped from <TT>P</TT> before the
reference is removed), and deduction fails.</P>

<P>It's not clear whether this is the intended outcome or
not.</P>

<P><B>Notes from the April, 2005 meeting:</B></P>

<P>The CWG observed that there is nothing special about either
<TT>bool</TT> or the context in the example above; instead, it
will be a problem wherever a copy occurs, because cv-qualification
is always dropped in a copy operation.  This appears to be a case
where the conversion deduction rules are not properly symmetrical
with the rules for arguments.  The example should be accepted.</P>

<BR><BR><HR><A NAME="586"></A><H4>586.
  
Default <I>template-argument</I>s and template argument deduction
</H4><B>Section: </B>14.8.2.5&#160;
 [temp.deduct.type]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Widman
 &#160;&#160;&#160;

 <B>Date: </B>20 June 2006<BR>




<P><A HREF="
     cwg_defects.html#226">Issue 226</A> removed the original
prohibition on default <I>template-argument</I>s for function
templates.  However, the note in 14.8.2.5
 [temp.deduct.type]
paragraph 19 still reflects that prohibition.  It should be revised
or removed.</P>

<BR><BR><HR><A NAME="475"></A><H4>475.
  
When is <TT>std::uncaught_exception()</TT> true? (take 2)
</H4><B>Section: </B>15.5.3&#160;
 [except.uncaught]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Martin Sebor
 &#160;&#160;&#160;

 <B>Date: </B>27 Sep 2004<BR>


<P> See also <A HREF="
     cwg_closed.html#37">issue 37</A>.</P>

<P>Given this piece of code and <TT>S</TT> having a user-defined
ctor, at precisely which point must
<TT>std::uncaught_exception()</TT> return <TT>true</TT> and where
<TT>false</TT>?</P>

<PRE>
    try { S s0; throw s0; } catch (S s2) { }
</PRE>

<P>My understanding of the semantics of the code is as
follows:</P>

<OL>

<LI>The throw expression creates a temporary for a copy of
<TT>s0</TT>, say <TT>s1</TT>, using the copy ctor of
<TT>S</TT>. In this invocation of the copy ctor
<TT>uncaught_exception()</TT> must return <TT>true</TT>.</LI>

<LI><TT>s0</TT> is destroyed during stack unwinding. In the
invocation of <TT>S</TT> dtor <TT>uncaught_exception()</TT> must
still return <TT>true</TT>.</LI>

<LI>The variable <TT>s2</TT> is initialized from <TT>s1</TT> by
invoking the copy ctor of <TT>S</TT>. In this invocation
<TT>uncaught_exception()</TT> must also return
<TT>true</TT>.</LI>

<LI><TT>s2</TT> and <TT>s1</TT> are destroyed. In the invocations
of <TT>S</TT> dtor <TT>uncaught_exception()</TT> must return
<TT>false</TT>.</LI>

</OL>

<P>Is my understanding correct?</P>

<P>15.1
 [except.throw] paragraph 3 talks about &#8220;the
exception object&#8221; when describing the semantics of the
<I>throw-expression</I>:</P>

<BLOCKQUOTE>
a <I>throw-expression</I> initializes a temporary object, called
the <I>exception object</I>...  </BLOCKQUOTE>

<P>However, 15.5.1
 [except.terminate] paragraph 1 talks about
&#8220;the expression to be thrown&#8221; when enumerating the
conditions under which <TT>terminate()</TT> is called:</P>

<BLOCKQUOTE>
when the exception handling mechanism, after completing
evaluation of the expression to be thrown but before the
exception is caught (15.1
 [except.throw]), calls a user
function that exits via an uncaught exception... </BLOCKQUOTE>

<P>And, 15.5.3
 [except.uncaught] paragraph 1 refers to
&#8220;the object to be thrown&#8221; in the description of
<TT>uncaught_exception()</TT>:</P>

<BLOCKQUOTE>
The function <TT>std::uncaught_exception()</TT> returns
<TT>true</TT> after completing evaluation of the object to be
thrown... </BLOCKQUOTE>

<P>Are all these objects one and the same? I believe the answer
is important in case the construction of the temporary exception
object throws another exception.</P>

<P>Suppose they are the same. Then <TT>uncaught_exception()</TT>
invoked from the copy ctor for <TT>s1</TT> (from the example
[above]) must return <TT>false</TT> and a new exception (e.g.,
<TT>bad_alloc</TT>) may be thrown and caught by a matching
handler (i.e., without calling <TT>terminate()</TT>).</P>

<P>But if they are not the same, then
<TT>uncaught_exception()</TT> invoked from the copy ctor for
<TT>s1</TT> must return <TT>true</TT> and throwing another
exception would end up calling <TT>terminate()</TT>. This would,
IMO, have pretty severe consequences on writing exception safe
exception classes.</P>

<P>As in the first case, different compilers behave differently,
with most compilers not calling <TT>terminate()</TT> when the
ctor for the temporary exception object throws. Unfortunately,
the two compilers that I trust the most do call
<TT>terminate()</TT>.</P>

<P>FWIW, my feeling is that it should be possible for the copy
ctor invoked to initialize the temporary exception object to
safely exit by throwing another exception, and that the new
exception should be allowed to be caught without calling
<TT>terminate</TT>.</P>

<P><U>Mike Miller</U>: The way I see this, a <I>throw-expression</I> has an 
<I>assignment-expression</I> as an operand.  This expression is
&#8220;the expression to be thrown.&#8221; Evaluation of this
expression yields an object; this object is &#8220;the object to
be thrown.&#8221; This object is then copied to the exception
object.</P>

<P><U>Martin Sebor</U>: Here's a survey of the return value from
<TT>uncaught_exception()</TT> in the various stages of exception
handling, implemented by current compilers:</P>

<TABLE FRAME="BOX" RULES="ALL">
<THEAD>
<TR>
<TH></TH>
<TH>expr</TH>
<TH>temp</TH>
<TH>unwind</TH>
<TH>handlr</TH>
<TH>2nd ex</TH>
</TR>
</THEAD>
<TBODY>
<TR>
<TD>HP aCC 6</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">1</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">OK</TD>
</TR>
<TR>
<TD>Compaq C++ 6.5</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">1</TD>
<TD ALIGN="CENTER">1</TD>
<TD ALIGN="CENTER">ABRT</TD>
</TR>
<TR>
<TD>EDG eccp 3.4</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">1</TD>
<TD ALIGN="CENTER">1</TD>
<TD ALIGN="CENTER">1</TD>
<TD ALIGN="CENTER">ABRT</TD>
</TR>
<TR>
<TD>g++ 3.4.2</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">1</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">OK</TD>
</TR>
<TR>
<TD>Intel C++ 7.0</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">1</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">OK</TD>
</TR>
<TR>
<TD>MIPSpro 7.4.1</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">1</TD>
<TD ALIGN="CENTER">1</TD>
<TD ALIGN="CENTER">ABRT</TD>
</TR>
<TR>
<TD>MSVC 7.0</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">1</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">OK</TD>
</TR>
<TR>
<TD>SunPro 5.5</TD>
<TD ALIGN="CENTER">1</TD>
<TD ALIGN="CENTER">1</TD>
<TD ALIGN="CENTER">1</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">OK</TD>
</TR>
<TR>
<TD>VisualAge 6.0</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">1</TD>
<TD ALIGN="CENTER">1</TD>
<TD ALIGN="CENTER">1</TD>
<TD ALIGN="CENTER">OK</TD>
</TR>
</TBODY>
</TABLE>

<P>In the table above:</P>

<UL>
<TABLE FRAME="VOID" RULES="NONE" CELLPADDING="10">
<TR>
<TD VALIGN="TOP">expr</TD>
<TD VALIGN="TOP">is the evaluation of the <I>assignment-expression</I> in the
<I>throw-expression</I></TD>
</TR>
<TR>
<TD VALIGN="TOP">temp</TD>
<TD VALIGN="TOP">is the invocation of the copy ctor for the unnamed temporary
exception object created by the runtime.</TD>
</TR>
<TR>
<TD VALIGN="TOP">unwind</TD>
<TD VALIGN="TOP">is stack unwinding.</TD>
</TR>
<TR>
<TD VALIGN="TOP">handlr</TD>
<TD VALIGN="TOP">is the invocation of the copy ctor in the
<I>exception-declaration</I> in the catch handler.</TD>
</TR>
<TR>
<TD VALIGN="TOP">2nd ex</TD>
<TD VALIGN="TOP">describes the behavior of the implementation when the
invocation of the copy ctor for the unnamed temporary exception
object [temp] throws another exception.</TD>
</TR>
</TABLE>
</UL>

<P><B>Proposed resolution (October, 2004):</B></P>

<OL>

<LI><P>Change 15.1
 [except.throw] paragraph 3 as
follows:</P>

<BLOCKQUOTE>

A <I>throw-expression</I> initializes a temporary object, called the
<I>exception object</I>, <S>the</S> <B>by copying the <I>thrown
object</I> (i.e., the result of evaluating its
<I>assignment-expression</I> operand) to it. The</B> type of
<S>which</S> <B>the exception object</B> is determined by
removing any top-level <I>cv-qualifier</I>s from the static type
of the operand of <TT>throw</TT> and adjusting the type from
&#8220;array of <TT>T</TT>&#8221; or &#8220;function returning
<TT>T</TT>&#8221; to &#8220;pointer to <TT>T</TT>&#8221; or
&#8220;pointer to function returning <TT>T</TT>,&#8221;
respectively.  [<I>Note:</I> the temporary object created <S>for</S>
<B>by</B> a <I>throw-expression</I> <S>that</S> <B>whose
operand</B> is a string literal is never of type <TT>char*</TT>
or <TT>wchar_t*</TT>; that is, the special conversions for string
literals from the types &#8220;array of <TT>const
char</TT>&#8221; and &#8220;array of <TT>const
wchar_t</TT>&#8221; to the types &#8220;pointer to
<TT>char</TT>&#8221; and &#8220;pointer to
<TT>wchar_t</TT>,&#8221; respectively (4.2
 [conv.array]), are never applied to <B>the operand of</B> a
<I>throw-expression</I>. &#8212;<I>end note</I>] The temporary is
an lvalue and is used to initialize the variable named in the
matching handler (15.3
 [except.handle]).  The type of the
<B>operand of a</B> <I>throw-expression</I> shall not be an
incomplete type, or a pointer to an incomplete type other than
(possibly cv-qualified) <TT>void</TT>. [...]

</BLOCKQUOTE>

</LI>

<LI><P>Change the note in 15.3
 [except.handle] paragraph 3
as follows:</P>

<BLOCKQUOTE>

[<I>Note:</I> a <I>throw-expression</I> <B>operand that</B>
<S>which</S> is an integral constant expression of integer type
that evaluates to zero does not match a handler of pointer type;
that is, the null pointer constant conversions (4.10
 [conv.ptr], 4.11
 [conv.mem]) do not
apply. &#8212;<I>end note</I>]

</BLOCKQUOTE>

</LI>

<LI><P>Change 15.5.1
 [except.terminate] paragraph 1 bullet 1
as follows:</P>

<BLOCKQUOTE>

when the exception handling mechanism, after completing
evaluation of the <S>expression to be thrown</S> <B>operand of
<TT>throw</TT></B> but before the exception is caught
(15.1
 [except.throw]), calls a user function that exits
via an uncaught exception,

</BLOCKQUOTE>

</LI>

<LI><P>Change 15.5.3
 [except.uncaught] paragraph 1 as
follows:</P>

<BLOCKQUOTE>

The function <TT>std::uncaught_exception()</TT> returns
<TT>true</TT> after completing evaluation of the <S>object to be
thrown</S> <B>operand of <TT>throw</TT></B> until completing the
initialization of the <I>exception-declaration</I> in the
matching handler (18.7.4
 [uncaught]).

</BLOCKQUOTE>

</LI>

<LI><P>Change 18.7.4
 [uncaught] paragraph 1 by adding
the indicated words:</P>

<BLOCKQUOTE>

<I>Returns:</I> <TT>true</TT> after completing evaluation of
<B>the operand of</B> a <I>throw-expression</I> until either
completing initialization of the <I>exception-declaration</I> in
the matching handler or entering <TT>unexpected()</TT> due to the
throw; or after entering <TT>terminate()</TT> for any reason
other than an explicit call to <TT>terminate()</TT>.
[<I>Note:</I> This includes stack unwinding (15.2
 [except.ctor]). &#8212;<I>end note</I>]

</BLOCKQUOTE>

</LI>

</OL>

<P><B>Notes from the April, 2005 meeting:</B></P>

<P>The CWG discussed this resolution both within the group and with
other interested parties.  Among the points that were made:</P>

<UL><LI><P>Martin Sebor  pointed to a
<A HREF="http://gcc.gnu.org/ml/libstdc++/2005-01/msg00033.html">posting</A>
in which he argues that writing copy constructors is more difficult if
an exception during the copy to the exception object will result in a
call to <TT>std::terminate()</TT>.</P>
</LI>

<LI><P>In response to a question about why the copy to the exception
object is different from the copy from the exception object to the
object in the <I>exception-declaration</I>, it was observed that the
writer of the handler can avoid the second copy (by using a reference
declaration), but the first copy is unavoidable.</P></LI>

<LI><P>John Spicer observed that not exiting via exception should be a
design constraint for copy constructors in exception objects,
regardless of whether <TT>std::terminate()</TT> is called or
not.</P></LI>

<LI><P>Adopting the position that <TT>uncaught_exception()</TT>
returns <TT>false</TT> during the copy to the exception object would
reduce the differences between the case where that copy is elided and
the case where it is performed.</P></LI>

<LI><P>Jason Merrill observed that making <TT>uncaught_exception()</TT>
return <TT>false</TT> during the copy to the exception object would
simplify the code generated by g++; as it currently stands, the
compiler must generate code to catch exceptions during that copy so
<TT>std::terminate()</TT> can be called.</P></LI>

<LI><P>Bjarne Stroustrup worried that allowing the copy constructor to
throw an exception during the copy to the exception object could
result in a serious and specific exception being silently transformed
into a more trivial and generic one (although the CWG later noted that
this risk already exists if something in the expression being thrown
throws an exception before the expression completes).</P></LI>

</UL>

<P>The CWG felt that more input from a wider audience was necessary
before a decision could be made on the appropriate resolution.
</P>

<P><B>Notes from the April, 2006 meeting:</B></P>

<P>The CWG agreed with the position that <TT>std::uncaught_exception()</TT>
should return <TT>false</TT> during the copy to the exception object
and that <TT>std::terminate()</TT> should not be called if that
constructor exits with an exception.  The issue was returned to
&#8220;drafting&#8221; status for rewording to reflect this position.</P>

<P><B>Additional notes (September, 2007):</B></P>

<P>Although this issue deals primarily with when
<TT>std::uncaught_exception()</TT> begins to return <TT>true</TT>, the
specification of when it begins to return <TT>false</TT> is also
problematic.  There are two parallel sections that define the meaning
of <TT>std::uncaught_exception()</TT> and each has a different
problem.  15.5.3
 [except.uncaught] reads,</P>

<BLOCKQUOTE>

The function <TT>std::uncaught_exception()</TT> returns <TT>true</TT>
after completing evaluation of the object to be thrown until
completing the initialization of the <I>exception-declaration</I> in
the matching handler (18.7.4
 [uncaught]).

</BLOCKQUOTE>

<P>The problem here is that whether an exception is considered
caught (the underlying condition tested by the function) is here
presented in terms of having initialized the <I>exception-declaration</I>,
while in other places it is specified by having an active handler for
the exception, e.g., 15.1
 [except.throw] paragraph 6:</P>

<BLOCKQUOTE>

An exception is considered caught when a handler for that exception
becomes active (15.3
 [except.handle]).

</BLOCKQUOTE>

<P>This distinction is important because of 15.3
 [except.handle]
paragraph 3:</P>

<BLOCKQUOTE>

A handler is considered active when initialization is complete for the
formal parameter (if any) of the catch clause.  [<I>Note:</I> the
stack will have been unwound at that point. &#8212;<I>end note</I>]
Also, an implicit handler is considered active
when <TT>std::terminate()</TT> or <TT>std::unexpected()</TT> is
entered due to a throw.

</BLOCKQUOTE>

<P>Note that there is no <I>exception-declaration</I> to be
initialized for the <TT>std::terminate()</TT> and
<TT>std::unexpected()</TT> cases; nevertheless, according to
18.7.4
 [uncaught], <TT>std::uncaught_exception()</TT>
is supposed to return <TT>false</TT> when one of those two functions
is entered.</P>

<P>The specification in 18.7.4
 [uncaught] is not well
phrased, however, and is open to misinterpretation.  It reads,</P>

<BLOCKQUOTE>

<I>Returns:</I> <TT>true</TT> after completing evaluation of a
<I>throw-expression</I> until either completing initialization of the
<I>exception-declaration</I> in the matching handler or entering
<TT>unexpected()</TT> due to the throw; or after
entering <TT>terminate()</TT> for any reason other than an explicit
call to <TT>terminate()</TT>.

</BLOCKQUOTE>

<P>The problem here is lack of parallelism: does &#8220;after
entering <TT>terminate</TT>&#8221; refer to the condition for returning
<TT>true</TT> or <TT>false</TT>?  This would be better phrased along
the lines of</P>

<BLOCKQUOTE>

<I>Returns:</I> <TT>true</TT> after completing evaluation of a
<I>throw-expression</I> until a handler for the exception becomes
active (15.3
 [except.handle]).

</BLOCKQUOTE>

<BR><BR><HR><A NAME="618"></A><H4>618.
  
Casts in preprocessor conditional expressions
</H4><B>Section: </B>16.1&#160;
 [cpp.cond]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Martin Sebor
 &#160;&#160;&#160;

 <B>Date: </B>12 February 2007<BR>




<P>16.1
 [cpp.cond] paragraph 1 states,</P>

<BLOCKQUOTE>

The expression that controls conditional inclusion shall be an
integral constant expression except that: it shall not contain a
cast...

</BLOCKQUOTE>

<P>The prohibition of casts is vacuous and misleading: as
pointed out in the footnote in that paragraph, </P>

<BLOCKQUOTE>

Because the controlling constant expression is evaluated during
translation phase 4, all identifiers either are or are not macro names
&#8212; there simply are no keywords, enumeration constants, and so on.

</BLOCKQUOTE>

<P>As a result, there can be no casts, which require either
keywords or identifiers that resolve to types in order to be
recognized as casts.  The wording on casts should be removed and
replaced by a note recognizing this implication.</P>

<P><B>Notes from the April, 2007 meeting:</B></P>

<P>The CWG agreed with this suggested resolution; however, the
reference is in the &#8220;Preprocessing Directives&#8221; clause,
which WG21 intends to keep in as close synchronization as possible
with the corresponding wording in the C Standard.  Any change here
must therefore be done in consultation with WG14.  Clark Nelson will
fulfill this liaison function.</P>

<P>It was also noted that the imminent introduction of
<TT>constexpr</TT> also has the potential for a similar kind of
confusion, so the proposed resolution should address both casts and
<TT>constexpr</TT>.</P>

<BR><BR><BR><BR><HR><A NAME="Open Status"></A><H3>Issues with "Open" Status</H3>
<HR><A NAME="248"></A><H4>248.
  
Identifier characters
</H4><B>Section: </B>_N2691_.E&#160;
 [extendid]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>6 Oct 2000<BR>




<P>The list of identifier characters specified in the C++ standard
annex _N2691_.E
 [extendid] and the C99 standard annex D are
different.  The C99 standard includes more characters.</P>

<P>The C++ standard says that the characters are from "ISO/IEC PDTR
10176" while the C99 standard says "ISO/IEC TR 10176".  I'm guessing
that the PDTR is an earlier draft of the TR.</P>

<P>Should the list in the C++ standard be updated?</P>

<P><U>Tom Plum</U>: In my opinion, the "identifier character" issue
has not been resolved with certainty within SC22.</P>

<P>One critical difference in C99 was the decision to allow a compiler
to accept more characters than are given in the annex.  This allows
for future expansion.</P>

<P>The broader issue concerns the venue in which the "identifier
character" issue will receive ongoing resolution.</P>

<P><B>Notes from 10/00 meeting:</B></P>

<P>The core language working group expressed a strong preference
(13/0/5 in favor/opposed/abstaining) that the list of identifier
characters should be extensible, as is the case in C99.  However,
the fact that this topic is under active discussion by other bodies
was deemed sufficient reason to defer any changes to the C++
specification until the situation is more stable.</P>

<P><B>Notes from October, 2005 meeting:</B></P>

<P>The working group expressed interest in the kind of approach taken by
<A href="http://www.w3.org/TR/2004/REC-xml11-20040204/#NT-NameStartChar">
XML 1.1</A>, in which the definition of an identifier character is done
by excluding large ranges of the Unicode character set and accepting any
character outside those ranges, rather than by affirmatively designating
each identifier character in each language.  As noted above, 
consideration of this issue was previously deferred pending other
related standardization efforts.  Clark Nelson will investigate whether
these have reached a point at which progress on this issue in C++ is now
possible.</P>

<P><B>Additional note (May, 2008):</B></P>

<P><A HREF="
     cwg_defects.html#663">Issue 663</A> also deals with this
appendix, and the proposed resolution there is to update the
table to reflect the newest available technical report, ISO/IEC
TR 10176:2003.  That resolution might be seen as sufficient for
this issue, as well.  However, that approach does not address
several of the concerns mentioned in the discussion above:
coordination with WG14, the extensibility of the list of
identifiers, the alternative approach used in the XML
specification, etc.</P>

<BR><BR><HR><A NAME="616"></A><H4>616.
  
Definition of &#8220;indeterminate value&#8221;
</H4><B>Section: </B>1.3&#160;
 [intro.defs]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Bjarne Stroustrup
 &#160;&#160;&#160;

 <B>Date: </B>2 February 2007<BR>




<P>The C++ Standard uses the phrase &#8220;indeterminate value&#8221;
without defining it.  C99 defines it as &#8220;either an unspecified
value or a trap representation.&#8221;  Should C++ follow suit?</P>

<P>In addition, 4.1
 [conv.lval] paragraph 1 says that
applying the lvalue-to-rvalue conversion to an &#8220;object
[that] is uninitialized&#8221; results in undefined behavior;
this should be rephrased in terms of an object with an
indeterminate value.</P>

<BR><BR><HR><A NAME="129"></A><H4>129.
  
Stability of uninitialized auto variables
</H4><B>Section: </B>1.9&#160;
 [intro.execution]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Nathan Myers
 &#160;&#160;&#160;

 <B>Date: </B>26 June 1999<BR>





<P>Does the Standard require that an uninitialized auto variable have
a stable (albeit indeterminate) value?  That is, does the Standard
require that the following function return <TT>true</TT>?</P>

<PRE>
    bool f() {
        unsigned char i;  // not initialized
        unsigned char j = i;
        unsigned char k = i;
        return j == k;    // true iff "i" is stable
    }
</PRE>

3.9.1
 [basic.fundamental]
 paragraph 1
requires that uninitialized <TT>unsigned char</TT> variables have a
valid value, so the initializations of <TT>j</TT> and <TT>k</TT> are
well-formed and required not to trap.  The question here is whether
the value of <TT>i</TT> is allowed to change between those
initializations.

<P><U>Mike Miller</U>:
1.9
 [intro.execution]
 paragraph 10 says,</P>

<BLOCKQUOTE>
An instance of each object with automatic storage
duration (3.7.3
 [basic.stc.auto]
) is
associated with each entry into
its block.  Such an object exists and retains its
last-stored value during the execution of the block
and while the block is suspended...
</BLOCKQUOTE>

I think that the most reasonable way to read this is that the
only thing that is allowed to change the value of an automatic
(non-volatile?) value is a "store" operation in the abstract
machine.  There are no "store" operations to <TT>i</TT> between the
initializations of <TT>j</TT> and <TT>k</TT>, so it must retain its
original (indeterminate but valid) value, and the result of
the program is well-defined.

<P>The quibble, of course, is whether the wording "last-stored
value" should be applied to a "never-stored" value.  I
think so, but others might differ.</P>

<P><U>Tom Plum</U>:
7.1.6.1
 [dcl.type.cv]
 paragraph 8 says,</P>

<BLOCKQUOTE>
[<I>Note:</I> <TT>volatile</TT> is a hint to the implementation
to avoid aggressive
optimization involving
the object because the value of the object might be changed by means
undetectable 
by an implementation. See
1.9
 [intro.execution]
 for detailed
semantics. In general, the semantics
of <TT>volatile</TT>
are intended to be the same in C++ as they are in C. ]
</BLOCKQUOTE>

&gt;From this I would infer that non-volatile means "shall not be
changed
by means undetectable by an implementation"; that the compiler is entitled to
safely cache accesses to non-volatile objects if it can prove that no
"detectable"
means can modify them; and that therefore  i  <I>shall</I>
maintain the same value
during the example above.

<P><U>Nathan Myers</U>:
This also has practical code-generation consequences.  If the
uninitialized auto variable lives in a register, and its value is 
<I>really</I> unspecified, then until it is initialized that register 
can be used as a temporary.  Each time it's "looked at" the variable
has the value that last washed up in that register.  After it's 
initialized it's "live" and cannot be used as a temporary any more, 
and your register pressure goes up a notch.  Fixing the uninit'd 
value would make it "live" the first time it is (or might be) looked 
at, instead.</P>

<P><U>Mike Ball</U>:
I agree with this.  I also believe that it was certainly never
my intent that an uninitialized variable be stable, and I would
have strongly argued against such a provision.  Nathan has well
stated the case.
And I am quite certain that it would be disastrous for optimizers.
To ensure it, the frontend would have to generate an initializer,
because optimizers track not only the lifetimes of variables, but
the lifetimes of values assigned to those variables.  This would
put C++ at a significant performance disadvantage compared to
other languages.  Not even Java went this route.  Guaranteeing 
defined behavior for a very special case of a generally undefined
operation seems unnecessary.</P>
<BR><BR><HR><A NAME="698"></A><H4>698.
  
The definition of &#8220;sequenced before&#8221; is too narrow
</H4><B>Section: </B>1.9&#160;
 [intro.execution]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jens Maurer
 &#160;&#160;&#160;

 <B>Date: </B>13 July, 2008<BR>




<P>According to 1.9
 [intro.execution] paragraph 14, &#8220;sequenced
before&#8221; is a relation between &#8220;evaluations.&#8221;  However,
3.6.3
 [basic.start.term] paragraph 3 says,</P>

<BLOCKQUOTE>

If the completion of the initialization of a non-local object with
static storage duration is sequenced before a call to
<TT>std::atexit</TT> (see <TT>&lt;cstdlib&gt;</TT>, 18.4
 [support.start.term]), the call to the function passed to <TT>std::atexit</TT>
is sequenced before the call to the destructor for the object. If a
call to <TT>std::atexit</TT> is sequenced before the completion of the
initialization of a non-local object with static storage duration, the
call to the destructor for the object is sequenced before the call to
the function passed to <TT>std::atexit</TT>. If a call to
<TT>std::atexit</TT> is sequenced before another call to
<TT>std::atexit</TT>, the call to the function passed to the second
<TT>std::atexit</TT> call is sequenced before the call to the function
passed to the first <TT>std::atexit</TT> call.

</BLOCKQUOTE>

<P>Except for the calls to <TT>std::atexit</TT>, these events do not
correspond to &#8220;evaluation&#8221; of expressions that appear in
the program.  If the &#8220;sequenced before&#8221; relation is to be
applied to them, a more comprehensive definition is needed.</P>

<BR><BR><HR><A NAME="726"></A><H4>726.
  
Atomic and non-atomic objects in the memory model
</H4><B>Section: </B>1.10&#160;
 [intro.multithread]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Clark Nelson
 &#160;&#160;&#160;

 <B>Date: </B>30 September, 2008<BR>


<P>In general, the description of the memory model is very careful to specify when the objects under discussion are atomic or non-atomic. However, there are a few cases where it could be clearer:</P>

<OL>
<LI><P>Modify 1.10
 [intro.multithread] paragraph 5 as follows:</P></LI>

<BLOCKQUOTE>

All modifications to a particular atomic object <I>M</I>
occur in some particular total order, called the
<I>modification order of M</I>. If <I>A</I> and <I>B</I> are
modifications of an atomic object <I>M</I> and <I>A</I> happens before
(as defined below) <I>B</I>, then <I>A</I> shall precede <I>B</I> in
the modification order of <I>M</I>, which is defined below.
[<I>Note:</I> This states that the modification orders must respect
<I>happens before</I>.  &#8212;<I>end note</I>] [<I>Note:</I> There is
a separate order for each <S>scalar</S> <B>atomic</B> object.  There
is no requirement that these can be combined into a single total order
for all objects.  In general this will be impossible since different
threads may observe modifications to different variables in
inconsistent orders. &#8212;<I>end note</I>]

</BLOCKQUOTE>

<LI><P>Modify 1.10
 [intro.multithread] paragraph 7 as follows:</P></LI>

<BLOCKQUOTE>

Certain library calls <I>synchronize with</I> other library calls
performed by another thread.  In particular, an atomic operation
<I>A</I> that performs a release operation on an <B>atomic</B> object
<I>M</I> synchronizes with an atomic operation <I>B</I> that performs
an acquire operation on <I>M</I> and reads a value written by any side
effect in the release sequence headed by <I>A</I>...

</BLOCKQUOTE>

<LI><P>Modify 1.10
 [intro.multithread] paragraph 12 as follows:</P></LI>

<BLOCKQUOTE>

A <I>visible side effect A</I> on <S>an</S> <B>a scalar</B> object
<B>or bit-field</B> <I>M</I> with respect to a value computation
<I>B</I> of <I>M</I> satisfies the conditions...

</BLOCKQUOTE>

</OL>

<BR><BR><HR><A NAME="740"></A><H4>740.
  
Incorrect note on data races
</H4><B>Section: </B>1.10&#160;
 [intro.multithread]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Wolf Lammen
 &#160;&#160;&#160;

 <B>Date: </B>3 November, 2008<BR>


<P>1.10
 [intro.multithread] paragraph 12 says,</P>

<BLOCKQUOTE>

<P>A <I>visible side effect A</I> on an object <I>M</I> with
respect to a value computation <I>B</I> of <I>M</I> satisfies the
conditions:</P>

<UL><LI><P><I>A</I> happens before <I>B</I>, and</P></LI>

<LI><P>there is no other side effect <I>X</I> to <I>M</I> such that
<I>A</I> happens before <I>X</I> and <I>X</I> happens before
<I>B</I>.</P></LI>

</UL>

<P>The value of a non-atomic scalar object <I>M</I>, as determined by
evaluation <I>B</I>, shall be the value stored by the visible side
effect <I>A</I>. [<I>Note:</I> If there is ambiguity about which side
effect to a non-atomic object is visible, then there is a data race,
and the behavior is undefined.  &#8212;<I>end note</I>]</P>

</BLOCKQUOTE>

<P>The note here suggests that, except in the case of a data race,
visible side effects to value computation can always be determined.
But unsequenced and indeterminately sequenced side effects on the same
object create ambiguities with respect to a later value computation as
well. So the wording needs to be revisited, see the following
examples.</P>

<PRE>
    int main(){
      int i = 0;
      i = // unsequenced side effect A
      i++; // unsequenced side effect B
      return i; // value computation C
    }
</PRE>

<P>According to the definition in the draft, both A and B are visible
side effects to C. However, there is no data race, because (paragraph
14) a race involves at least two threads. So the note in paragraph 12
is logically false.</P>

<P>The model introduces the special case of indeterminately sequenced
side effects, that leave open what execution order is taken in a
concrete situation. If the execution paths access the same data,
unpredictable results are possible, just as it is the case with data
races. Whereas data races constitute undefined behavior,
indeterminatedly sequenced side effects on the same object do not. As
a consequence of this disparity, indeterminately sequenced execution
occasionally needs exceptional treatment.</P>

<PRE>
    int i = 0;
    int f(){
      return
      i = 1; // side effect A
    }
    int g(){
      return
      i = 2; // side effect B
    }
    int h(int, int){
      return i; // value computation C
    }
    int main(){
      return h(f(),g()); // function call D returns 1 or 2?
    }
</PRE>

<P>Here, either A or B is the visible side effect on the value
computation C, but you cannot tell which (cf. 1.9
 [intro.execution]
paragraph 16).  Although an ambiguity is present, it is neither
because of a data race, nor is the behavior undefined, in total
contradiction to the note.</P>

<BR><BR><HR><A NAME="578"></A><H4>578.
  
Phase 1 replacement of characters with <I>universal-character-name</I>s
</H4><B>Section: </B>2.1&#160;
 [lex.phases]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Martin Vejn&#225;r
 &#160;&#160;&#160;

 <B>Date: </B>7 May 2006<BR>


<P>According to 2.1
 [lex.phases] paragraph 1, in translation
phase 1,</P>

<BLOCKQUOTE>

Any source file character not in the basic source character set
(2.2
 [lex.charset]) is replaced by the
universal-character-name that designates that character.

</BLOCKQUOTE>

<P>If a character that is not in the basic character set is preceded
by a backslash character, for example</P>

<PRE>
    "\&#225;"
</PRE>

<P>the result is equivalent to</P>

<PRE>
    "\\u00e1"
</PRE>

<P>that is, a backslash character followed by the spelling of the
universal-character-name.  This is different from the result in C99,
which accepts characters from the extended source character set without
replacing them with universal-character-names.</P>

<BR><BR><HR><A NAME="411"></A><H4>411.
  
Use of universal-character-name in character versus string literals
</H4><B>Section: </B>2.13.4&#160;
 [lex.string]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Kanze
 &#160;&#160;&#160;

 <B>Date: </B>23 Apr 2003<BR>


<P>2.13.4
 [lex.string] paragraph 5 reads</P>
<BLOCKQUOTE>
Escape sequences and
universal-character-names in string literals have the same meaning as in
character literals, except that the single quote ' is representable
either by itself or by the escape sequence \', and the double quote "
shall be preceded by a \. In a narrow string literal, a
universal-character-name may map to more than one char element due to
multibyte encoding.
</BLOCKQUOTE>

<P>The first sentence refers us to 2.13.2
 [lex.ccon],
where we read in the
first paragraph that "An ordinary character literal that contains a
single c-char has type char [...]."  Since the grammar shows that a
universal-character-name is a c-char, something like '\u1234' must have
type char (and thus be a single char element); in paragraph 5, we read
that "A universal-character-name is translated to the encoding, in the
execution character set, of the character named.  If there is no such
encoding, the universal-character-name is translated to an
implemenation-defined encoding."</P>

<P>This is in obvious contradiction with the second sentence.  In addition,
I'm not really clear what is supposed to happen in the case where the
execution (narrow-)character set is UTF-8.  Consider the character
\u0153 (the oe in the French word oeuvre).  Should '\u0153' be a char,
with an "error" value, say '?' (in conformance with the requirement that
it be a single char), or an int, with the two char values 0xC5, 0x93, in
an implementation defined order (in conformance with the requirement
that a character representable in the execution character set be
represented).  Supposing the former, should "\u0153" be the equivalent of
"?" (in conformance with the first sentence), or "\xC5\x93" (in
conformance with the second).</P>

<P><B>Notes from October 2003 meeting:</B></P>

<P>We decided we should forward this to the C committee and let them
resolve it.  Sent via e-mail to John Benito on November 14, 2003.</P>

<P><B>Reply from John Benito:</B></P>
<BLOCKQUOTE>
<P>I talked this over with the C project editor, we believe this was
handled by the C committee before publication of the current standard.</P>

<P>WG14 decided there needed to be a more restrictive rule 
for one-to-one mappings: rather than saying "a single c-char" 
as C++ does, the C standard says "a single character that
maps to a single-byte execution character"; WG14 fully expect
some (if not many or even most) UCNs to map to multiple characters.</P>

<P>Because of the fundamental differences between C and C++ character
types, I am not sure the C committee is qualified to answer this
satisfactorily for WG21.  WG14 is willing to review any decision reached
for compatibility.</P>

<P>I hope this helps.</P>
</BLOCKQUOTE>

<BR><BR><HR><A NAME="719"></A><H4>719.
  
Specifications for <I>operator-function-id</I> that should also apply to <I>literal-operator-id</I>
</H4><B>Section: </B>3&#160;
 [basic]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>19 September, 2008<BR>


<P>When user-defined literals were added, a new form of operator
function was created.  Presumably many of the existing
specifications that deal with <I>operator-function-id</I>s (the
definition of <I>name</I>, for instance, in paragraph 4 of
3
 [basic]) should also apply to
<I>literal-operator-id</I>s.</P>

<BR><BR><HR><A NAME="758"></A><H4>758.
  
Missing cases of declarations that are not definitions
</H4><B>Section: </B>3.1&#160;
 [basic.def]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Bjarne Stroustrup
 &#160;&#160;&#160;

 <B>Date: </B>22 January, 2009<BR>




<P>The list of declarations that are not definitions given in
3.1
 [basic.def] paragraph 2 does not mention several plausible
candidates: parameter declarations in non-defining function declarations,
non-static data members, and template parameters.  It might be argued
that none of these are <I>declaration</I>s (paragraph 1 does not use the
syntactic non-terminal <I>declaration</I> but does explicitly refer to
clause 7
 [dcl.dcl], where that non-terminal is defined).
However, the list in paragraph 2 does mention static member declarations,
which also are not <I>declaration</I>s, so the intent is not clear.</P>

<BR><BR><HR><A NAME="712"></A><H4>712.
  
Are integer constant operands of a <I>conditional-expression</I> &#8220;used?&#8221;
</H4><B>Section: </B>3.2&#160;
 [basic.def.odr]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>9 September, 2008<BR>


<P>In describing static data members initialized inside the class
definition, 9.4.2
 [class.static.data] paragraph 3 says,</P>

<BLOCKQUOTE>

The member shall still be defined in a namespace scope if it is
used in the program...

</BLOCKQUOTE>

<P>The definition of &#8220;used&#8221; is in 3.2
 [basic.def.odr]
paragraph 1:</P>

<BLOCKQUOTE>

An object or non-overloaded function whose name appears as a
potentially-evaluated expression is <I>used</I> unless it is an
object that satisfies the requirements for appearing in a
constant expression (5.19
 [expr.const]) and the
lvalue-to-rvalue conversion (4.1
 [conv.lval]) is
immediately applied.

</BLOCKQUOTE>

<P>Now consider the following example:</P>

<PRE>
    struct S {
      static const int a = 1;
      static const int b = 2;
    };
    int f(bool x) {
      return x ? S::a : S::b;
    }
</PRE>

<P>According to the current wording of the Standard, this example
requires that <TT>S::a</TT> and <TT>S::b</TT> be defined in a
namespace scope.  The reason for this is that, according to
5.16
 [expr.cond] paragraph 4, the result of this
<I>conditional-expression</I> is an lvalue and the
lvalue-to-rvalue conversion is applied to that, not directly
to the object, so this fails the &#8220;immediately applied&#8221;
requirement.  This is surprising and unfortunate, since only the
values and not the addresses of the static data members are used.
(This problem also applies to the proposed resolution of
<A HREF="
     cwg_active.html#696">issue 696</A>.)</P>

<BR><BR><HR><A NAME="481"></A><H4>481.
  
Scope of template parameters
</H4><B>Section: </B>3.3&#160;
 [basic.scope]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Gabriel Dos Reis
 &#160;&#160;&#160;

 <B>Date: </B>01 Nov 2004<BR>




<P>Sections 3.3.2
 [basic.scope.local] to 3.3.6
 [basic.scope.class] define and summarize different kinds of scopes
in a C++ program.  However it is missing a description for the
scope of template parameters.  I believe a section is needed
there &#8212; even though some information may be found in clause
14.</P>

<BR><BR><HR><A NAME="191"></A><H4>191.
  
Name lookup does not handle complex nesting
</H4><B>Section: </B>3.4.1&#160;
 [basic.lookup.unqual]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alan Nash
 &#160;&#160;&#160;

 <B>Date: </B>29 Dec 1999<BR>





<P>The current description of unqualified name lookup in
3.4.1
 [basic.lookup.unqual]
 paragraph 8 does
not correctly handle complex cases of nesting.  The Standard
currently reads,</P>

<BLOCKQUOTE>
A name used in the definition of a function that is a member function
(9.3) of a class <TT>X</TT> shall be declared in one of the following
ways:

<BR><UL>
<LI>before its use in the block in which it is used or in an enclosing
block (6.3), or</LI>

<LI>shall be a member of class <TT>X</TT> or be a member of a base
class of <TT>X</TT> (10.2), or</LI>

<LI>if <TT>X</TT> is a nested class of class <TT>Y</TT> (9.7), shall
be a member of <TT>Y</TT>, or shall be a member of a base class of
<TT>Y</TT> (this lookup applies in turn to <TT>Y</TT>'s enclosing
classes, starting with the innermost enclosing class), or</LI>

<LI>if <TT>X</TT> is a local class (9.8) or is a nested class of a
local class, before the definition of class <TT>X</TT> in a block
enclosing the definition of class <TT>X</TT>, or</LI>

<LI>if <TT>X</TT> is a member of namespace <TT>N</TT>, or is a nested
class of a class that is a member of <TT>N</TT>, or is a local class
or nested class within a local class of a function that is a member of
<TT>N</TT>, before the member function definition, in namespace
<TT>N</TT> or in one of <TT>N</TT>'s enclosing namespaces.</LI>
</UL>
</BLOCKQUOTE>

In particular, this formulation does not handle the following example:

<PRE>
    struct outer {
        static int i;
        struct inner {
            void f() {
                struct local {
                    void g() {
                        i = 5;
                    }
                };
            }
        };
    };
</PRE>

Here the reference to <TT>i</TT> is from a member function of a local
class of a member function of a nested class.  Nothing in the rules
allows <TT>outer::i</TT> to be found, although intuitively it should
be found.

<P>A more comprehensive formulation is needed that allows traversal of
any combination of blocks, local classes, and nested classes.
Similarly, the final bullet needs to be augmented so that a function
need not be a (direct) member of a namespace to allow searching that
namespace when the reference is from a member function of a class
local to that function.  That is, the current rules do not allow the
following example:</P>

<PRE>
    int j;    // global namespace
    struct S {
        void f() {
            struct local2 {
                void g() {
                    j = 5;
                }
            };
        }
    };
</PRE>
<BR><BR><HR><A NAME="192"></A><H4>192.
  
Name lookup in parameters
</H4><B>Section: </B>3.4.1&#160;
 [basic.lookup.unqual]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alan Nash
 &#160;&#160;&#160;

 <B>Date: </B>6 Jan 2000<BR>





<P>The description of name lookup in the
<I>parameter-declaration-clause</I> of member functions in
3.4.1
 [basic.lookup.unqual]
 paragraphs 7-8 is
flawed in at least two regards.</P>

<P>First, both paragraphs 7 and 8 apply to the
<I>parameter-declaration-clause</I> of a member function definition
and give different rules for the lookup.  Paragraph 7 applies to names
"used in the definition of a class <TT>X</TT> outside of a member
function body...," which includes the
<I>parameter-declaration-clause</I> of a member function definition,
while paragraph 8 applies to names following the function's
<I>declarator-id</I> (see the proposed resolution of
<A HREF="
     cwg_defects.html#41">issue 41</A>), including the
<I>parameter-declaration-clause</I>.</P>

<P>Second, paragraph 8 appears to apply to the type names used in the
<I>parameter-declaration-clause</I> of a member function defined
inside the class definition.  That is, it appears to allow the
following code, which was not the intent of the Committee:</P>

<PRE>
    struct S {
        void f(I i) { }
        typedef int I;
    };
</PRE>
<BR><BR><HR><A NAME="405"></A><H4>405.
  
Unqualified function name lookup
</H4><B>Section: </B>3.4.1&#160;
 [basic.lookup.unqual]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>William M. Miller
 &#160;&#160;&#160;

 <B>Date: </B>14 Apr 2003<BR>


<P>There seems to be some confusion in the Standard regarding the
relationship between 3.4.1
 [basic.lookup.unqual] (Unqualified name
lookup) and 3.4.2
 [basic.lookup.argdep]
(Argument-dependent lookup).  For example,
3.4.1
 [basic.lookup.unqual] paragraph 3 says,</P>

<BLOCKQUOTE>
The lookup for an unqualified name used as the
<I>postfix-expression</I> of a function call is described in
3.4.2
 [basic.lookup.argdep].
</BLOCKQUOTE>

<P>In other words, nothing in 3.4.1
 [basic.lookup.unqual]
applies to function names; the entire lookup is described in
3.4.2
 [basic.lookup.argdep].</P>

<P>3.4.2
 [basic.lookup.argdep] does not appear to share this
view of its responsibility.
The closest it comes is in 3.4.2
 [basic.lookup.argdep] paragraph 2a:</P>

<BLOCKQUOTE>
...the set of declarations found by the lookup of the function
name is the union of the set of declarations found using ordinary
unqualified lookup and the set of declarations found in the namespaces
and classes associated with the argument types.
</BLOCKQUOTE>

<P>Presumably, "ordinary unqualified lookup" is a reference
to the processing described in
3.4.1
 [basic.lookup.unqual], but, as noted above,
3.4.1
 [basic.lookup.unqual]
explicitly precludes applying that processing to function names.  The
details of "ordinary unqualified lookup" of function names
are not described anywhere.</P>

<P>The other clauses that reference
3.4.2
 [basic.lookup.argdep], clauses
13
 [over] and 14
 [temp], are
split over the question of the relationship between
3.4.1
 [basic.lookup.unqual] and 3.4.2
 [basic.lookup.argdep].
13.3.1.1.1
 [over.call.func] paragraph 3, for instance, says</P>

<BLOCKQUOTE>
The name is looked up in the context of the function call
following the normal rules for name lookup in function calls
(3.4.2
 [basic.lookup.argdep]).
</BLOCKQUOTE>

<P>I.e., this reference assumes that
3.4.2
 [basic.lookup.argdep] is self-contained.  The
same is true of 13.3.1.2
 [over.match.oper] paragraph 3,
second bullet:</P>

<BLOCKQUOTE>
The set of non-member candidates is the result of the
unqualified lookup of operator@ in the context of the expression
according to the usual rules for name lookup in unqualified function
calls (3.4.2
 [basic.lookup.argdep]), except that all member
functions are ignored.
</BLOCKQUOTE>

<P>On the other hand, however, 14.6.4.2
 [temp.dep.candidate]
paragraph 1 explicitly assumes that
3.4.1
 [basic.lookup.unqual] and 3.4.2
 [basic.lookup.argdep] are
both involved in function name lookup and do different things:</P>

<BLOCKQUOTE>
For a function call that depends on a template parameter, if
the function name is an <I>unqualified-id</I> but not a
<I>template-id</I>, the candidate functions are found using the usual
lookup rules (3.4.1
 [basic.lookup.unqual],
3.4.2
 [basic.lookup.argdep]) except that:
<UL>
<LI>For the part of the lookup using unqualified name lookup
(3.4.1
 [basic.lookup.unqual]),
only function declarations with external linkage from the template
definition context are found.</LI>

<LI>For the part of the lookup using associated
namespaces (3.4.2
 [basic.lookup.argdep]),
only function declarations with external linkage found in either the
template definition context or the template instantiation context are
found.</LI>
</UL>
</BLOCKQUOTE>

<B><P>Suggested resolution:</P></B>

<P>Change 3.4.1
 [basic.lookup.unqual] paragraph 1 from</P>

<BLOCKQUOTE>
...name lookup ends as soon as a declaration is found for the
name.
</BLOCKQUOTE>

<P>to</P>

<BLOCKQUOTE>
...name lookup ends with the first scope containing one or more
declarations of the name.
</BLOCKQUOTE>

<P>Change the first sentence of 3.4.1
 [basic.lookup.unqual]
paragraph 3 from</P>

<BLOCKQUOTE>
The lookup for an unqualified name used as the
<I>postfix-expression</I> of a function call is described in
3.4.2
 [basic.lookup.argdep].
</BLOCKQUOTE>

<P>to</P>

<BLOCKQUOTE>
An unqualified name used as the <I>postfix-expression</I> of a
function call is looked up as described below.  In addition,
argument-dependent lookup (3.4.2
 [basic.lookup.argdep]) is
performed on this name to
complete the resulting set of declarations.
</BLOCKQUOTE>

<BR><BR><HR><A NAME="321"></A><H4>321.
  
Associated classes and namespaces for argument-dependent lookup
</H4><B>Section: </B>3.4.2&#160;
 [basic.lookup.argdep]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Andrei Iltchenko
 &#160;&#160;&#160;

 <B>Date: </B>12 Nov 2001<BR>


<P>The last bullet of the second paragraph of section
3.4.2
 [basic.lookup.argdep] says that:</P>
<BLOCKQUOTE>
If T is a template-id, its associated namespaces and classes are the
namespace in which the template is defined; for member templates, the member
template's class; the namespaces and classes associated with the types of
the template arguments provided for template type parameters (excluding
template template parameters); the namespaces in which any template template
arguments are defined; and the classes in which any member templates used as
template template arguments are defined.
</BLOCKQUOTE>

<P>The first problem with this wording is that it is misleading, since one
cannot get such a function argument whose type would be a template-id. The
bullet should be speaking about template specializations instead.</P>

<P>The second problem is owing to the use of the word "defined" in the phrases
"are the namespace in which the template is defined", "in which any template
template arguments are defined", and "as template template arguments are
defined". The bullet should use the word "declared" instead, since scenarios
like the one below are possible:</P>
<PRE>
namespace  A  {

   template&lt;class T&gt;
   struct  test  {

      template&lt;class U&gt;
      struct  mem_templ  {   };

   };

   // declaration in namespace 'A'
   template&lt;&gt; template&lt;&gt;
   struct  test&lt;int&gt;::mem_templ&lt;int&gt;;

   void  foo(test&lt;int&gt;::mem_templ&lt;int&gt;&amp;)
   {   }

}

// definition in the global namespace
template&lt;&gt; template&lt;&gt;
struct  A::test&lt;int&gt;::mem_templ&lt;int&gt;  {
};

int  main()
{
   A::test&lt;int&gt;::mem_templ&lt;int&gt;   inst;
   // According to the current definition of 3.4.2
   // foo is not found.
   foo(inst);
}
</PRE>

<P>In addition, the bullet doesn't make it clear whether a T which is a class
template specialization must also be treated as a class type, i.e. if the
contents of the second bullet of the second paragraph of section
3.4.2
 [basic.lookup.argdep].
<BLOCKQUOTE>
<UL>
<LI>
If T is a class type (including unions), its associated classes are: the
class itself; the class of which it is a member, if any; and its direct and
indirect base classes. Its associated namespaces are the namespaces in which
its associated classes are defined.
[This wording is as updated by core issue 90.]
</LI>
</UL>
</BLOCKQUOTE>
must apply to it or not. The same stands for a T which is a function
template specialization. This detail can make a difference in an example
such as the one below:
<PRE>
template&lt;class T&gt;
struct  slist_iterator  {
   friend bool  operator==(const slist_iterator&amp; x, const slist_iterator&amp; y)
   {   return  true;   }
};

template&lt;class T&gt;
struct  slist  {
   typedef slist_iterator&lt;T&gt;   iterator;
   iterator  begin()
   {   return  iterator();   }
   iterator  end()
   {   return  iterator();   }
};

int  main()
{
   slist&lt;int&gt;   my_list;
   slist&lt;int&gt;::iterator   mi1 = my_list.begin(),  mi2 = my_list.end();
   // Must the the friend function declaration
   // bool  operator==(const slist_iterator&lt;int&gt;&amp;, const slist_iterator&lt;int&gt;&amp;);
   // be found through argument dependent lookup? I.e. is the specialization
   // 'slist&lt;int&gt;' the associated class of the arguments 'mi1' and 'mi2'. If we
   // apply only the contents of the last bullet of 3.4.2/2, then the type
   // 'slist_iterator&lt;int&gt;' has no associated classes and the friend declaration
   // is not found.
   mi1 == mi2;
}
</PRE>
</P>

<P><B>Suggested resolution</B>:</P>

<P>Replace the last bullet of the second paragraph of section
3.4.2
 [basic.lookup.argdep]
<BLOCKQUOTE>
<UL>
<LI>
If <TT>T</TT> is a <I>template-id</I>,
its associated namespaces and classes are the
namespace in which the template is defined; for member templates, the member
template's class; the namespaces and classes associated with the types of
the template arguments provided for template type parameters (excluding
template template parameters); the namespaces in which any template template
arguments are defined; and the classes in which any member templates used as
template template arguments are defined.
</LI>
</UL>
</BLOCKQUOTE>
with
<BLOCKQUOTE>
<UL>
<LI>
If <TT>T</TT> is a class template
specialization, its associated namespaces and
classes are those associated with <TT>T</TT> when
<TT>T</TT> is regarded as a class type; the
namespaces and classes associated with the types of the template arguments
provided for template type parameters (excluding template template
parameters); the namespaces in which the primary templates making template
template arguments are declared; and the classes in which any primary member
templates used as template template arguments are declared.
</LI>
<LI>
If <TT>T</TT> is a function template specialization,
its associated namespaces and
classes are those associated with <TT>T</TT> when
<TT>T</TT> is regarded as a function type;
the namespaces and classes associated with the types of the template
arguments provided for template type parameters (excluding template template
parameters); the namespaces in which the primary templates making template
template arguments are declared; and the classes in which any primary member
templates used as template template arguments are declared.
</LI>
</UL>
</BLOCKQUOTE>
</P>
<P>Replace the second bullet of the second paragraph of section
3.4.2
 [basic.lookup.argdep]
<BLOCKQUOTE>
<UL>
<LI>
If <TT>T</TT> is a class type (including unions),
its associated classes are: the
class itself; the class of which it is a member, if any; and its direct and
indirect base classes. Its associated namespaces are the namespaces in which
its associated classes are defined.
</LI>
</UL>
</BLOCKQUOTE>
with
<BLOCKQUOTE>
<UL>
<LI>
If <TT>T</TT> is a class type (including unions),
its associated classes are: the
class itself; the class of which it is a member, if any; and its direct and
indirect base classes. Its associated namespaces are the namespaces in which
its associated classes are declared [Note: in case of any of the associated
classes being a class template specialization, its associated namespace is
acually the namespace containing the declaration of the primary class
template of the class template specialization].
</LI>
</UL>
</BLOCKQUOTE>
</P>

<BR><BR><HR><A NAME="724"></A><H4>724.
  
Qualified name lookup in a constrained context
</H4><B>Section: </B>3.4.3&#160;
 [basic.lookup.qual]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daniel Kr&#252;gler
 &#160;&#160;&#160;

 <B>Date: </B>24 September, 2008<BR>




<P>According to 3.4.3
 [basic.lookup.qual] paragraph 7,</P>

<BLOCKQUOTE>

 In a constrained context (14.10
 [temp.constrained]), a name
 prefixed by a <I>nested-name-specifier</I> that nominates a template
 type parameter <TT>T</TT> is looked up as follows: for each template
 requirement <TT>C&lt;</TT><I>args</I><TT>&gt;</TT> whose template
 argument list references <TT>T</TT>, the name is looked up as if the
<I>nested-name-specifier</I> referenced
<TT>C&lt;</TT><I>args</I><TT>&gt;</TT> instead of <TT>T</TT>
(3.4.3.3
 [concept.qual]), except that only the names of
associated types are visible during this lookup. If an associated type
of at least one requirement is found, then each name found shall refer
to the same type.  Otherwise, if the reference to the name occurs
within a constrained context, the name is looked up within the scope
of the archetype associated with <TT>T</TT> (and no special
restriction on name visibility is in effect for this lookup).

</BLOCKQUOTE>

<P>In an example like,</P>

<PRE>
    concept A&lt;typename T&gt; {
      typename assoc_type;
    }

    concept B&lt;typename T&gt; {
      typename assoc_type;
    }

    template&lt;typename T&gt;
    requires A&lt;T&gt;
    B&lt;T::assoc_type&gt;::assoc_type f();
</PRE>

<P>it is not clear whether the argument <TT>T::assoc_type</TT> of
<TT>B</TT> &#8220;references&#8221; <TT>T</TT> or not.</P>

<P><U>James Widman</U>: In our mental model (and in our intentions
while drafting), we still have a (non-archetype) dependent type for
the <TT>T</TT> in your example, and, even after the <TT>SameType</TT>
requirement is seen, we also have a distinct dependent type to
represent <TT>A&lt;T&gt;::assoc_type</TT> (which itself is distinct
from the type of the entity named <TT>assoc_type</TT> that lives in
the scope of the concept <TT>A</TT>).  And those two dependent types
(<TT>A&lt;T&gt;::assoc_type</TT> and <TT>T</TT>) will both alias the
same type archetype when that archetype is established (see the
paragraph on establishment in 14.10.2
 [temp.archetype]).
</P>

<P>I think 3.4.3
 [basic.lookup.qual] paragraph 6 will read more
easily if we change the &#8220;references a template parameter&#8221;
verbiage to a generalized &#8220;dependent type&#8221; verbiage.  (We
shied away from that in the past because we wanted to say that there's
nothing &#8220;dependent&#8221; within a constrained context.  That's
because we wanted to say that all name references are bound to
something, overload resolution is done, etc.  So certainly there are
no instances of deferred name lookup or deferred overload resolution
within a constrained context.  But we still need to be able to say
when a type, template, value or concept instance depends on a template
parameter.)  I propose we change this wording to read,
</P>

<BLOCKQUOTE>

In a constrained context (14.10
 [temp.constrained]), the identifier
of an <I>unqualified-id</I> prefixed by a <I>nested-name-specifier</I>
that nominates a dependent type <TT>T</TT> is looked up as follows:
for each template requirement <TT>C&lt;</TT><I>args</I><TT>&gt;</TT>
such that either <TT>T</TT> or an equivalent type (14.10.1
 [temp.req]) is a template argument to <TT>C</TT>, the identifier of
the <I>unqualified-id</I> is looked up as if the
<I>nested-name-specifier</I> nominated
<TT>C&lt;</TT><I>args</I><TT>&gt;</TT> instead of <TT>T</TT>
(3.4.3.3
 [concept.qual]), except that only the names of
associated types and class templates (14.9.1.2
 [concept.assoc])
are visible during this lookup.  If an associated type or class
template of at least one requirement is found, then the
<I>unqualified-id</I> shall refer either to the same type or to an
equivalent type when its identifier is looked up in each of the
concepts of the other requirements where <TT>T</TT> is a template
argument.  [<I>Note:</I> no part of the procedure described in the
preceding part of this paragraph results in the establishment of an
archetype (14.10.2
 [temp.archetype]).  However, in the event that
the <I>unqualified-id</I> is a <I>template-id</I>, one of its template
arguments could contain some construct that would force archetype
establishment.  &#8212;<I>end note</I>] Otherwise, the name is looked
up within the scope of the archetype aliased by <TT>T</TT> (and no
special restriction on name visibility is in effect for this lookup).
[<I>Note:</I> this establishes the archetype of <TT>T</TT> (if it was
not established already).  &#8212;<I>end note</I>]

</BLOCKQUOTE>

<P>(It looks like we have a wording nit to fix in the archetype
establishment paragraph: it talks about a type archetype coming into
existence &#8220;when it is used [in some way].&#8221; It seems odd to
say that something is used in a particular way before it exists.  We
should instead say something like &#8220;when <I>a
necessarily-dependent type that would alias the archetype</I> is used
[in some way].&#8221;)</P>

<P>(It might also be nice to have a cleanup in the paragraph that
introduces the notion of <TT>std::SameType</TT> and &#8220;equivalent
types&#8221; (14.10.1
 [temp.req] paragraph 3) so that the
congruence relation is part of the normative text rather than a note.)
</P>

<BR><BR><HR><A NAME="562"></A><H4>562.
  
<I>qualified-id</I>s in non-expression contexts
</H4><B>Section: </B>3.4.3.1&#160;
 [class.qual]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>6 April 2006<BR>


<P>Both 3.4.3.1
 [class.qual] and 3.4.3.2
 [namespace.qual]
specify that some lookups are to be performed &#8220;in the context of the
entire <I>postfix-expression</I>,&#8221; ignoring the fact that
<I>qualified-id</I>s can appear outside of expressions.</P>

<P>It was suggested in document J16/05-0156 = WG21 N1896 that these
uses be changed to &#8220;the context in which the <I>qualified-id</I>
occurs,&#8221; but it isn't clear that this formulation adequately
covers all the places a <I>qualified-id</I> can occur.</P>

<BR><BR><HR><A NAME="278"></A><H4>278.
  
External linkage and nameless entities
</H4><B>Section: </B>3.5&#160;
 [basic.link]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>12 Apr 2000<BR>




<P>It is unclear to what extent entities without names match
across translation units.  For example,</P>

<PRE>
    struct S {
       int :2;
       enum { a, b, c } x;
       static class {} *p;
    };
</PRE>

<P>If this declaration appears in multiple translation units, are
all these members "the same" in each declaration?</P>

<P>A similar question can be asked about non-member declarations:</P>

<PRE>
    // Translation unit 1:
    extern enum { d, e, f } y;

    // Translation unit 2:
    extern enum { d, e, f } y;

    // Translation unit 3:
    enum { d, e, f } y;
</PRE>

<P>Is this valid C++?  Is it valid C?</P>

<P><U>James Kanze</U>: <TT>S::p</TT> cannot be defined, because to
do so requires a type specifier and the type cannot be named.
<TT>::y</TT> is valid C because C only requires compatible, not
identical, types.  In C++, it appears that there is a new type in
each declaration, so it would not be valid.  This differs from
<TT>S::x</TT> because the unnamed type is part of a named type
&#8212; but I don't know where or if the Standard says that.</P>

<P><U>John Max Skaller</U>:
It's not valid C++, because the type is a synthesised, unique name
for the enumeration type which differs across translation units, as if:</P>

<PRE>
    extern enum _synth1 { d,e,f} y;
    ..
    extern enum _synth2 { d,e,f} y;
</PRE>

<P>had been written.</P>

<P>However, within a class, the ODR implies the types are the same:</P>

<PRE>
    class X { enum { d } y; };
</PRE>

<P>in two translation units ensures that the type of member <TT>y</TT>
is the same: the two <TT>X</TT>'s obey the ODR and so denote the same class,
and it follows that there's only one member <TT>y</TT> and one type that it
has.</P>

<P>(See also issues <A HREF="
     cwg_closed.html#132">132</A> and
<A HREF="
     cwg_defects.html#216">216</A>.)</P>

<BR><BR><HR><A NAME="279"></A><H4>279.
  
Correspondence of "names for linkage purposes"
</H4><B>Section: </B>3.5&#160;
 [basic.link]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>4 Apr 2001<BR>




<P>The standard says that an unnamed class or enum definition can be given
a "name for linkage purposes" through a typedef.  E.g.,</P>

<PRE>
    typedef enum {} E;
    extern E *p;
</PRE>

<P>can appear in multiple translation units.</P>

<P>How about the following combination?</P>

<PRE>
    // Translation unit 1:
    struct S;
    extern S *q;

    // Translation unit 2:
    typedef struct {} S;
    extern S *q;
</PRE>

<P>Is this valid C++?</P>

<P>Also, if the answer is "yes", consider the following slight variant:</P>

<PRE>
    // Translation unit 1:
    struct S {};  // &lt;&lt;-- class has definition
    extern S *q;

    // Translation unit 2:
    typedef struct {} S;
    extern S *q;
</PRE>

<P>Is this a violation of the ODR because two definitions
of type <TT>S</TT> consist of differing token sequences?</P>

<BR><BR><HR><A NAME="338"></A><H4>338.
  
Enumerator name with linkage used as class name in other translation unit
</H4><B>Section: </B>3.5&#160;
 [basic.link]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>26 Feb 2002<BR>




<P>The following declarations are allowed within a translation
unit:</P>
<PRE>
  struct S;
  enum { S };
</PRE>
<P>However, 3.5
 [basic.link] paragraph 9 seems to say
these two declarations
cannot appear in two different translation units.  That also
would mean that the inclusion of a header containing the above
in two different translation units is not valid C++.</P>

<P>I suspect this is an oversight and that users should be allowed
to have the declarations above appear in different translation
units.  (It is a fairly common thing to do, I think.)</P>

<P><U>Mike Miller</U>:
I think you meant "<TT>enum E { S };</TT>" -- enumerators only have
external linkage if the enumeration does (3.5
 [basic.link]
paragraph 4), and 3.5
 [basic.link] paragraph 9 only
applies to entities with external linkage.</P>

<P>I don't remember why enumerators were given linkage; I don't
think it's necessary for mangling non-type template arguments.
In any event, I can't think why cross-TU name collisions between
enumerators and other entities would cause a problem, so I guess
a change here would be okay.  I can think of three changes that
would have that effect:</P>

<OL>
<LI>
Saying that enumerators do not have linkage.
</LI>
<LI>
Removing enumerators from the list of entities in the first
sentence of 3.5
 [basic.link] paragraph 9.
</LI>
<LI>
Saying that it's okay for an enumerator in one TU to have the
same name as a class type in another TU only if the enumerator
hides that same class type in both TUs (the example you gave).
</LI>
</OL>

<P><U>Daveed Vandevoorde</U>:
I don't think any of these are sufficient in the sense that the problem
isn't limited to enumerators.  E.g.:
<PRE>
  struct X;
  extern void X();
</PRE>
shouldn't create cross-TU collisions either.</P>

<P><U>Mike Miller</U>:
So you're saying that cross-TU collisions should only be
prohibited if both names denote entities of the same kind (both
functions, both objects, both types, etc.), or if they are both
references (regardless of what they refer to, presumably)?</P>

<P><U>Daveed Vandevoorde</U>:
Not exactly.  Instead, I'm saying that if two entities (with
external linkage) can coexist when they're both declared in the
same translation unit (TU), then they should also be allowed to
coexist when they're declared in two different translation units.</P>

<P>For example:
<PRE>
  int i;
  void i();  // Error
</PRE>
This is an error within a TU, so I don't see a reason to make it
valid across TUs.</P>

<P>However, "tag names" (class/struct/union/enum) can sometimes
coexist with identically named entities (variables, functions &amp;
enumerators, but not namespaces, templates or type names).</P>

<BR><BR><HR><A NAME="371"></A><H4>371.
  
Interleaving of constructor calls
</H4><B>Section: </B>3.6.2&#160;
 [basic.start.init]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Matt Austern
 &#160;&#160;&#160;

 <B>Date: </B>7 August 2002<BR>




<P>Is a compiler allowed to interleave constructor calls when
performing dynamic initialization of nonlocal objects?
What I mean by interleaving is: beginning to execute a
particular constructor, then going off and doing
something else, then going back to the original constructor.
I can't find anything explicit about this in clause
3.6.2
 [basic.start.init].</P>

<P>I'll present a few different examples, some of which get a
bit wild.  But a lot of what this comes down to is exactly
what the standard means when it talks about the order
of initialization.  If it says that some object x must be
initialized before a particular event takes place, does that
mean that x's constructor must be entered before that
event, or does it mean that it must be exited before that
event?  If object x must be initialized before object y,
does that mean that x's constructor must exit before y's
constructor is entered?</P>

<P>(The answer to that question might just be common sense,
but I couldn't find an answer in clause 3.6.2
 [basic.start.init].
Actually, when I read 3.6.2
 [basic.start.init]
carefully, I find there are a lot of things I took
for granted that aren't there.)</P>

<P>OK, so a few specific scenerios.</P>
<OL>
<LI>We have a translation unit with nonlocal objects A and B,
both of which require dynamic initialization.  A comes before
B.  A must be initialized before B.  May the compiler start
to construct A, get partway through the constructor, then
construct B, and then go back to finishing A?</LI>

<LI>We have a translation unit with nonlocal object A and
function f.  Construction of A is deferred until after the
first statement of main.  A must be constructed before the
first use of f.  Is the compiler permitted to start constructing
A, then execute f, then go back to constructing A?</LI>

<LI>We have nonlocal objects A and B, in two different
translation units.  The order in which A and B are constructed
is unspecified by the Standard.  Is the compiler permitted to
begin constructing A, then construct B, then finish A's
constructor?  Note the implications of a 'yes' answer.  If A's
and B's constructor both call some function f, then the call
stack might look like this:
<PRE>
   &lt;runtime gunk&gt;
     &lt;Enter A's constructor&gt;
        &lt;Enter f&gt;
           &lt;runtime gunk&gt;
              &lt;Enter B's constructor&gt;
                 &lt;Enter f&gt;
                 &lt;Leave f&gt;
              &lt;Leave B's constructor&gt;
        &lt;Leave f&gt;
     &lt;Leave A's constructor&gt;
</PRE>
The implication of a 'yes' answer for users is that any function
called by a constructor, directly or indirectly, must be reentrant.</LI>

<LI>This last example is to show why a 'no' answer to #3 might
be a problem too.  New scenerio: we've got one translation
unit containing a nonlocal object A and a function f1, and another
translation unit containing a nonlocal object B and a function f2.
A's constructor calls f2.  Initialization of A and B is deferred until
after the first statement of main().  Someone in main calls f1.
Question: is the compiler permitted to start constructing A, then
go off and construct B at some point before f2 gets called, then
go back and finish constructing A?  In fact, is the compiler
required to do that?  We've got an unpleasant tension here between
the bad implications of a 'yes' answer to #3, and the explicit
requirement in 3.6.2
 [basic.start.init] paragraph 3.</LI>
</OL>

<P>At this point, you might be thinking we could avoid all of this
nonsense by removing compilers' freedom to defer initialization
until after the beginning of main().  I'd resist that, for two reasons.
First, it would be a huge change to make after the standard has
been out.  Second, that freedom is necessary if we want to have
support for dynamic libraries.  I realize we don't yet say anything
about dynamic libraries, but I'd hate to make decisions that would
make such support even harder.</P>

<BR><BR><HR><A NAME="640"></A><H4>640.
  
Accessing destroyed local objects of static storage duration
</H4><B>Section: </B>3.6.3&#160;
 [basic.start.term]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Howard Hinnant
 &#160;&#160;&#160;

 <B>Date: </B>30 July 2007<BR>




<P>3.6.3
 [basic.start.term] paragraph 2 says,</P>

<BLOCKQUOTE>

If a function contains a local object of static storage duration
that has been destroyed and the function is called during the
destruction of an object with static storage duration, the
program has undefined behavior if the flow of control passes
through the definition of the previously destroyed local object.

</BLOCKQUOTE>

<P>I would like to turn this behavior from undefined to
well-defined behavior for the purpose of achieving a graceful
shutdown, especially in a multi-threaded world.</P>

<P>Background: Alexandrescu describes the &#8220;phoenix
singleton&#8221; in <I>Modern C++ Design</I>.  This is a class
used as a function local static, that will reconstruct itself,
and reapply itself to the <TT>atexit</TT> chain, if the program
attempts to use it after it is destructed in the <TT>atexit</TT>
chain.  It achieves this by setting a &#8220;destructed
flag&#8221; in its own state in its destructor.  If the object is
later accessed (and a member function is called on it), the
member function notes the state of the &#8220;destructed
flag&#8221; and does the reconstruction dance.  The phoenix
singleton pattern was designed to address issues only in
single-threaded code where accesses among static objects can have
a non-scoped pattern.  When we throw in multi-threading, and the
possibility that threads can be running after <TT>main</TT>
returns, the chances of accessing a destroyed static
significantly increase.</P>

<P>The very least that I would like to see happen is to standardize what  
I believe is existing practice:  When an object is destroyed in the  
<TT>atexit</TT> chain, the memory the object occupied is left in
whatever state the destructor put it in.  If this can only be
reliably done for objects with standard layout, that would be an
acceptable compromise.  This would allow objects to set &#8220;I'm
destructed&#8221; flags in their state and then do something
well-defined if accessed, such as throw an exception.</P>

<P>A possible refinement of this idea is to have the compiler set
up a 3-state flag around function-local statics instead of the
current 2-state flag:</P>

<UL>
<LI>Not constructed yet</LI>
<LI>Constructed but not destroyed yet</LI>
<LI>Destroyed</LI>
</UL>

<P>We have the first two states today.  We might choose to add
the third state, and if execution passes over a function-local
static with &#8220;destroyed&#8221; state, an exception could be
thrown.  This would mean that we would not have to guarantee
memory stability in destroyed objects of static duration.</P>

<P>This refinement would break phoenix singletons, and is not
required for the <TT>~mutex()</TT>/<TT>~condition()</TT> I've
described and prototyped.  But it might make it easier for Joe
Coder to apply this kind of guarantee to his own types.</P>

<BR><BR><HR><A NAME="365"></A><H4>365.
  
Storage duration and temporaries
</H4><B>Section: </B>3.7&#160;
 [basic.stc]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Kanze
 &#160;&#160;&#160;

 <B>Date: </B>24 July 2002<BR>


<P>There are several problems with 3.7
 [basic.stc]:</P>
<UL>
<LI>
<P>3.7
 [basic.stc] paragraph 2 says that "Static and automatic
storage durations are associated with objects introduced by
declarations (3.1
 [basic.def]) and implicitly created
by the implementation (12.2
 [class.temporary])."</P>

<P>In fact, objects "implicitly created by the implementation" are the
temporaries described in (12.2
 [class.temporary]), and have neither
static nor automatic storage duration, but a totally different duration,
described in 12.2
 [class.temporary].</P>
</LI>
<LI>
<P>3.7
 [basic.stc] uses the expression "local object" in several 
places, without ever defining it.  Presumably, what is meant is "an 
object declared at block scope", but this should be said explicitly.</P>

<P>In a recent discussion in comp.lang.c++.moderated, on poster 
interpreted "local objects" as including temporaries.  This would require them 
to live until the end of the block in which they are created, which
contradicts 12.2
 [class.temporary]. If temporaries are covered by
this section, and the statement in 3.7
 [basic.stc]
seems to suggest, and they aren't local objects, then they must have
static storage duration, which isn't right either.</P>

<P>I propose adding a fourth storage duration to the list after
3.7
 [basic.stc] paragraph 1:</P>
<UL>
<LI>
temporary storage duration
</LI>
</UL>
<P>And rewriting the second paragraph of this section as follows:</P>
<BLOCKQUOTE>
Temporary storage duration is associated with objects implicitly
created by the implementation, and is described in 12.2
 [class.temporary].
Static and automatic storage durations are associated with objects defined
by declarations; in the following, an object defined by a declaration
with block scope is a local object.  The dynamic storage duration is
associated with objects created by the <TT>operator new</TT>.
</BLOCKQUOTE>
</LI>
</UL>

<P><U>Steve Adamczyk</U>:
There may well be an issue here, but one should bear in mind the
difference between storage duration and object lifetime.  As far
as I can see, there is no particular problem with temporaries having
automatic or static storage duration, as appropriate.  The point
of 12.2
 [class.temporary] is that they have an unusual object
lifetime.</P>

<P><B>Notes from Ocrober 2002 meeting:</B></P>

<P>It might be desirable to shorten the storage duration of temporaries
to allow reuse of them.  The as-if rule allows some reuse, but such
reuse requires analysis, including noting whether the addresses of
such temporaries have been taken.</P>

<BR><BR><HR><A NAME="312"></A><H4>312.
  
&#8220;use&#8221; of invalid pointer value not defined
</H4><B>Section: </B>3.7.4.2&#160;
 [basic.stc.dynamic.deallocation]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Martin von Loewis
 &#160;&#160;&#160;

 <B>Date: </B>20 Sep 2001<BR>


<P>3.7.4.2
 [basic.stc.dynamic.deallocation] paragraph 4 mentions that the effect
of using an invalid pointer value is undefined. However, the standard
never says what it means to 'use' a value.</P>

<P>There are a number of possible interpretations, but it appears that
each of them leads to undesired conclusions:</P>
<OL>
<LI>
A value is 'used' in a program if a variable holding this value
appears in an expression that is evaluated.
This interpretation would render the sequence
<PRE>
   int *x = new int(0);
   delete x;
   x = 0;
</PRE>
into undefined behaviour. As this is a common idiom, this is
clearly undesirable.
</LI>
<LI>
A value is 'used' if an expression evaluates to that value.
This would render the sequence
<PRE>
   int *x = new int(0);
   delete x;
   x-&gt;~int();
</PRE>
into undefined behaviour; according to 5.2.4
 [expr.pseudo],
the variable x is
'evaluated' as part of evaluating the pseudo destructor call. This,
in turn, would mean that all containers (23
 [containers])
of pointers show
undefined behaviour, e.g. 23.2.4.3
 [list.modifiers]
requires to invoke the
destructor as part of the <TT>clear()</TT> method of the container.
</LI>
</OL>

<P>If any other meaning was intended for 'using an expression', that
meaning should be stated explicitly.</P>

<P>(See also <A HREF="
     cwg_closed.html#623">issue 623</A>.)</P>

<BR><BR><HR><A NAME="523"></A><H4>523.
  
Can a one-past-the-end pointer be invalidated by deleting an adjacent object?
</H4><B>Section: </B>3.7.4.2&#160;
 [basic.stc.dynamic.deallocation]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>comp.std.c++
 &#160;&#160;&#160;

 <B>Date: </B>8 July 2005<BR>


<P>When an object is deleted, 3.7.4.2
 [basic.stc.dynamic.deallocation] says
that the deallocation &#8220;[renders] invalid all pointers referring
to any part of the deallocated storage.&#8221; According to
3.9.2
 [basic.compound] paragraph 3, a pointer whose address is
one past the end of an array is considered to point to an unrelated
object that happens to reside at that address.  Does this need to be
clarified to specify that the one-past-the-end pointer of an array is
not invalidated by deleting the following object?  (See also
5.3.5
 [expr.delete] paragraph 4, which also mentions that
the system deallocation function renders a pointer invalid.)</P>

<BR><BR><HR><A NAME="735"></A><H4>735.
  
Missing case in specification of safely-derived pointers
</H4><B>Section: </B>3.7.4.3&#160;
 [basic.stc.dynamic.safety]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jens Maurer
 &#160;&#160;&#160;

 <B>Date: </B>14 October, 2008<BR>


<P>The bullets in 3.7.4.3
 [basic.stc.dynamic.safety] paragraph 2 do not
appear to cover the following example:</P>

<PRE>
   int&amp; i = *new int(5);
   // do something with i
   delete &amp;i;
</PRE>

<P>Should <TT>&amp;i</TT> be a safely-derived pointer value?</P>

<BR><BR><HR><A NAME="419"></A><H4>419.
  
Can cast to virtual base class be done on partially-constructed object?
</H4><B>Section: </B>3.8&#160;
 [basic.life]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Judy Ward
 &#160;&#160;&#160;

 <B>Date: </B>2 June 2003<BR>


<P>Consider</P>
<PRE>
  extern "C" int printf (const char *,...);

  struct Base { Base();};
  struct Derived: virtual public Base {
     Derived() {;}
  };

  Derived d;
  extern Derived&amp; obj = d;

  int i;

  Base::Base() {
    if ((Base *) &amp;obj) i = 4;
    printf ("i=%d\n", i);
  }

  int main() { return 0; }
</PRE>

<P>12.7
 [class.cdtor] paragraph 2 makes this valid, but
3.8
 [basic.life] paragraph 5 implies that it isn't valid.</P>

<P><U>Steve Adamczyk:</U>
A second issue:</P>
<PRE>
  extern "C" int printf(const char *,...);
  struct A                      { virtual ~A(); int x; };
  struct B : public virtual A   { };
  struct C : public B           { C(int); };
  struct D : public C           { D(); };
 
  int main()                    { D t; printf("passed\n");return 0; }
 
  A::~A()                       {} 
  C::C(int)                     {} 
  D::D() : C(this-&gt;x)           {}
</PRE>
<P><A HREF="
     cwg_defects.html#52">Core issue 52</A> almost, but not quite,
says that in evaluating "this-&gt;x"
you do a cast to the virtual base class A, which would be an error
according to 12.7
 [class.cdtor] paragraph 2 because the base
class B constructor hasn't started yet.
5.2.5
 [expr.ref] should be clarified to say that
the cast does need to get done.</P>

<P><U>James Kanze</U> submitted the same issue via comp.std.c++
on 11 July 2003:</P>
<BLOCKQUOTE>
Richard Smith:
Nonsense. You can use "this" perfectly happily in a constructor, just
be careful that (a) you're not using any members that are not fully
initialised, and (b) if you're calling virtual functions you know
exactly what you're doing.
</BLOCKQUOTE>

<P>In practice, and I think in intent, you are right.  However, the
standard makes some pretty stringent restrictions in
3.8
 [basic.life].  To start
with, it says (in paragraph 1): </P>
<BLOCKQUOTE>
    The lifetime of an object is a runtime property of the object.  The
    lifetime of an object of type T begins when:
<UL>
<LI>
        storage with the proper alignment and size for type T is
        obtained, and
</LI>
<LI>

        if T is a class type with a non-trivial constructor, the
        constructor calls has COMPLETED.
</LI>
</UL>
    The lifetime of an object of type T ends when:
<UL>
<LI>
        if T is a class type with a non-trivial destructor, the
        destructor call STARTS, or
</LI>
<LI>
        the storage which the object occupies is reused or released.
</LI>
</UL>
</BLOCKQUOTE>
(Emphasis added.)  Then when we get down to paragraph 5, it says:
<BLOCKQUOTE>
<P>
    Before the lifetime of an object has started but after the storage
    which the object will occupy has been allocated [which sounds to me
    like it would include in the constructor, given the text above] or,
    after the lifetime of an object has ended and before the storage
    which the object occupied is reused or released, any pointer that
    refers to the storage location where the object will be or was
    located may be used but only in limited ways. [...] If the object
    will be or was of a non-POD class type, the program has undefined
    behavior if:
</P>
<P>
    [...]
</P>
<UL>
<LI>
        the pointer is implicitly converted to a pointer to a base class
        type, or [...]
</LI>
</UL>
</BLOCKQUOTE>

<P>I can't find any exceptions for the this pointer.</P>

<P>Note that calling a non-static function in the base class, or even
constructing the base class in initializer list, involves an implicit
conversion of this to a pointer to the base class.  Thus undefined
behavior.  I'm sure that this wasn't the intent, but it would seem to be
what this paragraph is saying.</P>

<BR><BR><HR><A NAME="496"></A><H4>496.
  
Is a volatile-qualified type really a POD?
</H4><B>Section: </B>3.9&#160;
 [basic.types]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Maddock
 &#160;&#160;&#160;

 <B>Date: </B>30 Dec 2004<BR>




<P>In 3.9
 [basic.types] paragraph 10, the standard makes
it quite clear that volatile qualified types are PODs:</P>

<BLOCKQUOTE>

Arithmetic types (3.9.1
 [basic.fundamental]), enumeration
types, pointer types, and pointer to member types (3.9.2
 [basic.compound]), and <I>cv-qualified</I> versions of these
types (3.9.3
 [basic.type.qualifier]) are collectively called
<I>scalar types</I>. Scalar types, POD-struct types, POD-union
types (clause 9
 [class]), arrays of such types and
<I>cv-qualified</I> versions of these types (3.9.3
 [basic.type.qualifier]) are collectively called <I>POD types</I>.

</BLOCKQUOTE>

<P>However in 3.9
 [basic.types] paragraph 3, the
standard makes it clear that PODs can be copied &#8220;as
if&#8221; they were a collection of bytes by <TT>memcpy</TT>:</P>

<BLOCKQUOTE>

For any POD type <TT>T</TT>, if two pointers to <TT>T</TT> point to
distinct <TT>T</TT> objects <TT>obj1</TT> and <TT>obj2</TT>, where
neither <TT>obj1</TT> nor <TT>obj2</TT> is a base-class subobject, if
the value of <TT>obj1</TT> is copied into <TT>obj2</TT>, using
the <TT>std::memcpy</TT> library function, <TT>obj2</TT> shall
subsequently hold the same value as <TT>obj1</TT>.

</BLOCKQUOTE>

<P>The problem with this is that a volatile qualified type may
need to be copied in a specific way (by copying using only atomic
operations on multithreaded platforms, for example) in order to
avoid the &#8220;memory tearing&#8221; that may occur with a
byte-by-byte copy.</P>

<P>I realise that the standard says very little about volatile
qualified types, and nothing at all (yet) about multithreaded
platforms, but nonetheless this is a real issue, for the
following reason:</P>

<P>The forthcoming TR1 will define a series of traits that
provide information about the properties of a type, including
whether a type is a POD and/or has trivial construct/copy/assign
operations.  Libraries can use this information to optimise their
code as appropriate, for example an array of type <TT>T</TT>
might be copied with a <TT>memcpy</TT> rather than an
element-by-element copy if <TT>T</TT> is a POD.  This was one of
the main motivations behind the type traits chapter of the TR1.
However it's not clear how volatile types (or POD's which have a
volatile type as a member) should be handled in these cases.</P>

<P><B>Notes from the April, 2005 meeting:</B></P>

<P>It is not clear whether the volatile qualifier actually guarantees
atomicity in this way.  Also, the work on the memory model for
multithreading being done by the Evolution Working Group seems at this
point likely to specify additional semantics for volatile data, and
that work would need to be considered before resolving this issue.</P>

<BR><BR><HR><A NAME="146"></A><H4>146.
  
Floating-point zero
</H4><B>Section: </B>3.9.1&#160;
 [basic.fundamental]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Andy Sawyer
 &#160;&#160;&#160;

 <B>Date: </B>23 Jul 1999<BR>





<P>3.9.1
 [basic.fundamental]
 does not impose
a requirement on the floating point types that there be an exact
representation of the value zero.  This omission is significant in
4.12
 [conv.bool]
 paragraph 1, in which any
non-zero value converts to the <TT>bool</TT> value <TT>true</TT>.</P>

<P>Suggested resolution: require that all floating point types have an
exact representation of the value zero.</P>
<BR><BR><HR><A NAME="251"></A><H4>251.
  
How many signed integer types are there?
</H4><B>Section: </B>3.9.1&#160;
 [basic.fundamental]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Beman Dawes
 &#160;&#160;&#160;

 <B>Date: </B>18 Oct 2000<BR>




<P>3.9.1
 [basic.fundamental] paragraph 2 says that</P>

<BLOCKQUOTE>

There are four <I>signed integer types</I>: "<TT>signed char</TT>",
"<TT>short int</TT>", "<TT>int</TT>", and "<TT>long int</TT>."

</BLOCKQUOTE>

<P>This would indicate that <TT>const int</TT> is not a signed
integer type.</P>

<BR><BR><HR><A NAME="483"></A><H4>483.
  
Normative requirements on integral ranges
</H4><B>Section: </B>3.9.1&#160;
 [basic.fundamental]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Adamczyk
 &#160;&#160;&#160;

 <B>Date: </B>21 Oct 2004<BR>


<P>There is no normative requirement on the ranges of the integral
types, although the footnote in 3.9.1
 [basic.fundamental]
paragraph 2 indicates the intent (for <TT>int</TT>, at least)
that they match the values given in the <TT>&lt;climits&gt;</TT>
header.  Should there be an explicit requirement of some sort?</P>

<P>(See also paper N1693.)</P>

<BR><BR><HR><A NAME="689"></A><H4>689.
  
Maximum values of signed and unsigned integers
</H4><B>Section: </B>3.9.1&#160;
 [basic.fundamental]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Kanze
 &#160;&#160;&#160;

 <B>Date: </B>30 March, 2008<BR>




<P>The relationship between the values representable by corresponding
signed and unsigned integer types is not completely described, but
3.9
 [basic.types] paragraph 4 says,</P>

<BLOCKQUOTE>

The <I>value representation</I> of an object is the set of bits that
hold the value of type <TT>T</TT>.

</BLOCKQUOTE>

<P>and 3.9.1
 [basic.fundamental] paragraph 3 says,</P>

<BLOCKQUOTE>

The range of nonnegative values of a signed integer type is a
subrange of the corresponding unsigned integer type, and the
value representation of each corresponding signed/unsigned type
shall be the same.

</BLOCKQUOTE>

<P>I.e., the maximum value of each unsigned type must be larger
than the maximum value of the corresponding signed type.</P>

<P>C90 doesn't have this restriction, and C99 explicitly says
(6.2.6.2, paragraph 2),</P>

<BLOCKQUOTE>

For signed integer types, the bits of the object representation
shall be divided into three groups: value bits, padding bits, and
the sign bit. There need not be any padding bits; there shall be
exactly one sign bit. Each bit that is a value bit shall have the
same value as the same bit in the object representation of the
corresponding unsigned type (if there are <I>M</I> value bits in the
signed type and N in the unsigned type, then <I>M</I> &lt;= <I>N</I>).

</BLOCKQUOTE>

<P>Unlike C++, the sign bit is not part of the value, and on an
architecture that does not have native support of unsigned types,
an implementation can emulate unsigned integers by simply
ignoring what would be the sign bit in the signed type and be
conforming.</P>

<P>The question is whether we intend to make a conforming
implementation on such an architecture impossible. More
generally, what range of architectures do we intend to
support?  And to what degree do we want to follow C99 in
its evolution since C89?</P>

<P>(See paper J16/08-0141 = WG21 N2631.)</P>

<BR><BR><HR><A NAME="330"></A><H4>330.
  
Qualification conversions and pointers to arrays of pointers
</H4><B>Section: </B>4.4&#160;
 [conv.qual]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Roger Orr
 &#160;&#160;&#160;

 <B>Date: </B>2 Jan 2002<BR>


<P>Section 4.4
 [conv.qual]
covers the case of multi-level pointers, but does not appear to cover the
case of pointers to arrays of pointers.
The effect is that arrays are treated differently from simple scalar
values.</P>

<P>Consider for example the following code:
(from the thread "Pointer to array conversion question" begun in
comp.lang.c++.moderated)
<PRE>
  int main()
  {
     double *array2D[2][3];
  
     double       *       (*array2DPtr1)[3] = array2D;     // Legal
     double       * const (*array2DPtr2)[3] = array2DPtr1; // Legal
     double const * const (*array2DPtr3)[3] = array2DPtr2; // Illegal
  }
</PRE>
and compare this code with:-
<PRE>
  int main()
  {
     double *array[2];
  
     double       *       *ppd1 = array; // legal
     double       * const *ppd2 = ppd1;  // legal
     double const * const *ppd3 = ppd2;  // certainly legal (4.4/4)
  }
</PRE>
</P>

<P>The problem appears to be that the pointed to types in example 1 are
unrelated since nothing in the
relevant section of the standard covers it - 4.4
 [conv.qual]
does not mention conversions of the form
"cv array of N pointer to T"
into
"cv array of N pointer to cv T"</P>

<P>It appears that reinterpret_cast is the only way to perform the
conversion.</P>

<P><B>Suggested resolution:</B></P>

<P>Artem Livshits proposed a resolution :-</P>

<P>"I suppose if the definition of "similar" pointer types in
4.4
 [conv.qual] paragraph 4 was
rewritten like this:
<BLOCKQUOTE>
<P>T1 is cv1,0 P0 cv1,1 P1 ... cv1,n-1 Pn-1 cv1,n T</P>
<P>and</P>
<P>T2 is cv1,0 P0 cv1,1 P1 ... cv1,n-1 Pn-1 cv1,n T</P>

<P>where Pi is either a "pointer to" or a "pointer to an array of Ni"; besides
P0 may be also a "reference to" or a "reference to an array of N0" (in the
case of P0 of T2 being a reference, P0 of T1 may be nothing).</P>
</BLOCKQUOTE>
it would address the problem.</P>

<P>In fact I guess Pi in this notation may be also a "pointer to member", so
4.4
 [conv.qual]/{4,5,6,7} would be nicely wrapped in one
paragraph."</P>

<BR><BR><HR><A NAME="238"></A><H4>238.
  
Precision and accuracy constraints on floating point
</H4><B>Section: </B>5&#160;
 [expr]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Christophe de Dinechin
 &#160;&#160;&#160;

 <B>Date: </B>31 Jul 2000<BR>




<P>It is not clear what constraints are placed on a floating point
implementation by the wording of the Standard.  For instance, is
an implementation permitted to generate a "fused multiply-add"
instruction if the result would be different from what would
be obtained by performing the operations separately?  To what
extent does the "as-if" rule allow the kinds of optimizations
(e.g., loop unrolling) performed by FORTRAN compilers?</P>

<BR><BR><HR><A NAME="438"></A><H4>438.
  
Possible flaw in wording for multiple accesses to object between sequence points
</H4><B>Section: </B>5&#160;
 [expr]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jason Merrill
 &#160;&#160;&#160;

 <B>Date: </B>29 Oct 2003<BR>


<P>Lisa Lippincott mentioned this case to me:</P>
<PRE>
  A[0] = 0;
  A[A[0]] = 1;
</PRE>
<P>This seems to use the old value of A[0] other than to calculate the new
value, which is said to be undefined, but it also seems reasonable, since
the old value is used in order to select the object to modify, so there's
no ordering ambiguity.</P>

<P><U>Steve Adamczyk</U>: the ordering rule referred to is in
5
 [expr] paragraph 4.</P>

<P><B>Notes from the March 2004 meeting:</B></P>

<P>Clark Nelson mentions that the C committee may have done something on
this.</P>

<BR><BR><HR><A NAME="687"></A><H4>687.
  
<TT>template</TT> keyword with <I>unqualified-id</I>s
</H4><B>Section: </B>5.1&#160;
 [expr.prim]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mihai Rusu
 &#160;&#160;&#160;

 <B>Date: </B>27 February, 2008<BR>


<P>Consider the following:</P>

<PRE>
    namespace N {
        struct A { };
        template&lt;typename T&gt;
        T func(const A&amp;) { return T(); }
    }

    void f() {
        N::A a;
        func&lt;int&gt;(a);    //<SPAN STYLE="font-family:Times"><I> error</I></SPAN>
    }
</PRE>

<P>Although argument-dependent lookup would allow <TT>N::func</TT>
to be found in this call, the <TT>&lt;</TT> is taken as a
less-than operator rather than as the beginning of a template
argument list.  If the use of the <TT>template</TT> keyword for
syntactic disambiguation were permitted for <I>unqualified-id</I>s,
this problem could be solved by prefixing the function name with
<TT>template</TT>, allowing the <I>template-id</I> to be parsed
and argument-dependent lookup to be performed.</P>

<BR><BR><HR><A NAME="743"></A><H4>743.
  
Use of <TT>decltype</TT> in a <I>nested-name-specifier</I>
</H4><B>Section: </B>5.1&#160;
 [expr.prim]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jaakko J&#228;rvi
 &#160;&#160;&#160;

 <B>Date: </B>12 November, 2008<BR>




<P>The grammar for <I>nested-name-specifier</I> in 5.1
 [expr.prim]
paragraph 7 does not allow <TT>decltype</TT> to be used in a
<I>qualified-id</I>.  This could be useful for cases like:</P>

<PRE>
   auto vec = get_vec();
   decltype(vec)::value_type v = vec.first();
</PRE>

<BR><BR><HR><A NAME="760"></A><H4>760.
  
<TT>this</TT> inside a nested class of a non-static member function
</H4><B>Section: </B>5.1&#160;
 [expr.prim]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>3 February, 2009<BR>


<P><TT>this</TT> is a keyword and thus not subject to ordinary name
lookup.  That makes the interpretation of examples like the following
somewhat unclear:</P>

<PRE>
    struct outer {
      void f() {
        struct inner {
          int a[sizeof(*this)];  // #1
        };
      }
    };
</PRE>

<P>According to 5.1
 [expr.prim] paragraph 3,</P>

<BLOCKQUOTE>

The keyword <TT>this</TT> shall be used only inside a non-static class
member function body (9.3
 [class.mfct]) or in a
<I>brace-or-equal-initializer</I> for a non-static data member.

</BLOCKQUOTE>

<P>Should the use of <TT>this</TT> at #1 be interepreted as a well-formed
reference to <TT>outer::f()</TT>'s <TT>this</TT> or as an ill-formed
attempt to refer to a <TT>this</TT> for <TT>outer::inner</TT>?</P>

<P>One possible interpretation is that the intent is as if <TT>this</TT>
were an ordinary identifier appearing as a parameter in each non-static
member function.  (This view applies to the initializers of non-static
data members as well if they are considered to be rewritten as
<I>mem-initializer</I>s in the constructor body.)  Under this
interpretation, the prohibition against using <TT>this</TT> in other
contexts simply falls out of the fact that name lookup would fail to
find <TT>this</TT> anywhere else, so the reference in the example is
well-formed.  (Implementations vary in their treatment of this
example, so clearer wording is needed, whichever way the
interpretation goes.)</P>

<BR><BR><HR><A NAME="720"></A><H4>720.
  
Need examples of <I>lambda-expression</I>s
</H4><B>Section: </B>5.1.1&#160;
 [expr.prim.lambda]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>20 September, 2008<BR>


<P>There is not a single example of a <I>lambda-expression</I> in
their specification.  The Standard would be clearer if a few
judiciously-chosen examples were added.</P>

<BR><BR><HR><A NAME="750"></A><H4>750.
  
Implementation constraints on reference-only closure objects
</H4><B>Section: </B>5.1.1&#160;
 [expr.prim.lambda]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>10 December, 2008<BR>




<P>Consider an example like:</P>

<PRE>
    void f(vector&lt;double&gt; vec) {
      double x, y, z;
      fancy_algorithm(vec, [&amp;]() { /* use x, y, and z in various ways */ });
    }
</PRE>

<P>5.1.1
 [expr.prim.lambda] paragraph 8 requires that the closure
class for this lambda will have three reference members, and paragraph
12 requires that it be derived from <TT>std::reference_closure</TT>,
implying two additional pointer members.  Although 8.3.2
 [dcl.ref] paragraph 4 allows a reference to be implemented without
allocation of storage, current ABIs require that references be
implemented as pointers.  The practical effect of these requirements
is that the closure object for this lambda expression will contain
five pointers.  If not for these requirements, however, it would be
possible to implement the closure object as a single pointer to the
stack frame, generating data accesses in the function-call operator as
offsets relative to the frame pointer.  The current specification is
too tightly constrained.</P>

<P><U>Lawrence Crowl</U>:</P>

<P>The original intent was that the reference members could be omitted
from the closure object by an implementation.  The problem we had was
that we want the call to <TT>f</TT> in</P>

<PRE>
    extern f(std::reference_closure&lt;void()&gt;);
    extern f(std::function&lt;void()&gt;);
    f([&amp;](){});
</PRE>

<P>to unambiguously bind to the <TT>reference_closure</TT>; using
<TT>reference_closure</TT> can be an order of magnitude faster
than using <TT>function</TT>.</P>

<P>(See also <A HREF="
     cwg_active.html#751">issue 751</A>.)</P>

<BR><BR><HR><A NAME="751"></A><H4>751.
  
Deriving from closure classes
</H4><B>Section: </B>5.1.1&#160;
 [expr.prim.lambda]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>11 December, 2008<BR>




<P>During the discussion of <A HREF="
     cwg_active.html#750">issue 750</A>, it
was suggested that an implementation might be permitted to omit fields
in the closure object of a lambda expression if the implementation does
not need them to address the corresponding automatic variables.  If
permitted, this implementation choice might be visible to the program
via inheritance.  Consider:</P>

<PRE>
    void f() {
      int const N = 10;
      typedef decltype([&amp;N](){}) F;
      struct X: F {
        void n() { float z[N]; } // Error?
      };
    }
</PRE>

<P>If it is implementation-defined or unspecified whether the reference
member <TT>F::N</TT> will exist, then it is unknown whether the
the reference to <TT>N</TT> in <TT>X::n()</TT> will be an error
(because lookup finds <TT>F::N</TT>, which is private) or well-formed
(because there is no <TT>F::N</TT>, so the reference is to the local
automatic variable).</P>

<P>If implementations can omit fields, the implementation dependency
might be addressed by either treating the lookup &#8220;as if&#8221;
the fields existed, even if they are not present in the object
layout, or by defining the names of the fields in the closure class
to be unique identifiers, similar to the names of unnamed namespaces
(7.3.1.1
 [namespace.unnamed]).</P>

<P>Another suggestion was made that derivation from a closure class
should be prohibited, at least for now.  However, it was pointed out
that inheritance is frequently used to give stateless function objects
some state, suggesting a use case along the lines of:</P>

<PRE>
    template&lt;class T&gt; struct SomeState: T {
      // ...
    };
    template&lt;class F, typename T&lt; void algo(T functor, ...) {
      SomeState&lt;T&lt; state(functor);
      ...
    }

    ... algo([](int a){ return 2*a; }) ...
</PRE>

<BR><BR><HR><A NAME="752"></A><H4>752.
  
Name lookup in nested <I>lambda-expression</I>s
</H4><B>Section: </B>5.1.1&#160;
 [expr.prim.lambda]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>10 December, 2008<BR>




<P>How does name binding work in nested <I>lambda-expression</I>s? For
example,</P>

<PRE>
    void f1() {
      float v;
      []() { return [v]() { return v; } }
    }

    void f2() {
      float v;
      [v]() { return [v]() { return v; } }
    }
</PRE>

<P>According to 5.1.1
 [expr.prim.lambda] paragraph 3,</P>

<BLOCKQUOTE>

A name in the <I>lambda-capture</I> shall be in scope in the context
of the lambda expression, and shall be <TT>this</TT> or shall refer to
a local variable or reference with automatic storage duration.

</BLOCKQUOTE>

<P>One possible interpretation is that the lambda expression in
<TT>f1</TT> is ill-formed because <TT>v</TT> is used in the
<I>compound-statement</I> of the outer lambda expression but does not
appear in its effective capture set.  However, the appearance of
<TT>v</TT> in the inner <I>lambda-capture</I> is not a
&#8220;use&#8221; in the sense of 3.2
 [basic.def.odr] paragraph
2, because a <I>lambda-capture</I> is not an <I>expression</I>, and
it's not clear whether the reference in the inner lambda expression's
<TT>return</TT> expression should be considered a use of the automatic
variable or of the member of the inner lambda expression's closure
object.</P>

<P>Similarly, the lambda expression in <TT>f2</TT> could be deemed
to be ill-formed because the reference to <TT>N</TT> in the inner
lambda expression's <I>lambda-capture</I> would refer to the field
of the outer lambda-expression's closure object, not to a local
automatic variable; however, it's not clear whether the inner
lambda expression should be evaluated <I>in situ</I> or as part of
the generated <TT>operator()</TT> member of the outer lambda
expression's closure object.</P>

<BR><BR><HR><A NAME="753"></A><H4>753.
  
Array names in lambda capture sets
</H4><B>Section: </B>5.1.1&#160;
 [expr.prim.lambda]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>10 December, 2008<BR>




<P>The current specification does not adequately describe what happens
when an array name is part of the effective capture set of a lambda
expression.  5.1.1
 [expr.prim.lambda] paragraph 13 says that the
array member of the closure object is direct-initialized by the local
array; however, 8.5
 [dcl.init] paragraph 16 says that such
an initialization is ill-formed.  There are several possibilities for
handling this problem:</P>

<OL><LI><P>This results in an array member of the closure object,
which is initialized by copying each element, along the lines of
12.8
 [class.copy] paragraph 8.</P></LI>

<LI><P>This results in a pointer member of the closure object,
initialized to point to the first element of the array (i.e., the
array lvalue decays to a pointer rvalue).</P></LI>

<LI><P>This is ill-formed.</P></LI>

<LI><P>This results in a reference-to-array member of the closure
object, initialized to refer to the array, regardless of whether
<TT>&amp;</TT> was used or not.</P></LI>

<LI><P>This is ill-formed unless the capture is &#8220;by
reference.&#8221;</P></LI>

</OL>

<BR><BR><HR><A NAME="754"></A><H4>754.
  
Lambda expressions in default arguments of block-scope function declarations
</H4><B>Section: </B>5.1.1&#160;
 [expr.prim.lambda]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>10 December, 2008<BR>




<P>Is a lambda expression permitted in a default argument expression
for a block-scope function declaration? For example,</P>

<PRE>
    void g() {
      void f(std::reference_closure&lt;void()&gt; rc = []() {});
      f();
    }
</PRE>

<P>This was not discussed in either the Evolution Working Group nor
in the Core Working Group, and it is possible that some of the same
implementation difficulties that led to prohibiting use of automatic
variables in such default argument expressions (8.3.6
 [dcl.fct.default]
paragraph 7) might also apply to closure objects, even though they are
not autoamtic variables.</P>

<BR><BR><HR><A NAME="755"></A><H4>755.
  
Generalized <I>lambda-capture</I>s
</H4><B>Section: </B>5.1.1&#160;
 [expr.prim.lambda]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Freeman
 &#160;&#160;&#160;

 <B>Date: </B>11 December, 2008<BR>




<P>In the current specification of lambda expressions, a name appearing
in a <I>lambda-capture</I> must refer to a local variable or reference
with automatic storage duration (5.1.1
 [expr.prim.lambda] paragraph
3).  This restriction seems unnecessary and possibly confusing.</P>

<P>One possibility would be to extend the syntax of the
<I>lambda-capture</I> to be something like</P>

<BLOCKQUOTE>

<TT>v = </TT><I>expr</I>

</BLOCKQUOTE>

<P>with the meaning that the closure object would have a member
named <TT>v</TT> initialized with the value <I>expr</I>.  With this
extension, the current syntax could be viewed as an abbreviation
for</P>

<BLOCKQUOTE>

<TT>v = v</TT>

</BLOCKQUOTE>

<BR><BR><HR><A NAME="756"></A><H4>756.
  
Dropping cv-qualification on members of closure objects
</H4><B>Section: </B>5.1.1&#160;
 [expr.prim.lambda]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>15 December, 2008<BR>




<P>Consider the following example:</P>

<PRE>
    void f() {
      int const N = 10;
      [=]() mutable { N = 30; }  // Okay: this-&gt;N has type int, not int const.
      N = 20;  // Error.
    }
</PRE>

<P>That is, the <TT>N</TT> that is a member of the closure object is not
const, even though the captured variable is const.  This seems strange,
as capturing is basically a means of capturing the local environment in a
way that avoids lifetime issues.  More seriously, the change of type
means that the results of <TT>decltype</TT>, overload resolution, and
template argument deduction applied to a captured variable inside a
lambda expression can be different from those in the scope containing
the lambda expression, which could be a subtle source of bugs.</P>

<P>On the other hand, the copying involved in capturing has uses beyond
avoiding lifetime issues (taking snapshots of values, avoiding data
races, etc.), and the value of a cv-qualified object is not cv-qualified.</P>

<BR><BR><HR><A NAME="757"></A><H4>757.
  
Types without linkage in declarations
</H4><B>Section: </B>5.1.1&#160;
 [expr.prim.lambda]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>23 December, 2008<BR>




<P>Paper N2657, adopted at the June, 2008 meeting, removed the prohibition
of local and unnamed types as template arguments.  As part of the change,
3.5
 [basic.link] paragraph 8 was modified to read,</P>

<BLOCKQUOTE>

<P>A type without linkage shall not be used as the type of a variable or function with linkage, unless</P>

<UL>
<LI><P>the variable or function has extern "C" linkage (7.5
 [dcl.link]), or</P></LI>

<LI><P>the type without linkage was named using a dependent type
(14.6.2.1
 [temp.dep.type]).</P></LI>

</UL>

</BLOCKQUOTE>

<P>Because a type without linkage can only be named as a dependent type,
there are still some potentially useful things that cannot be done:</P>

<PRE>
    template &lt;class T&gt; struct A {
      friend void g(A, T);  // this can't be defined later
      void h(T);  // this cannot be explicitly specialized
    };

    template &lt;class T&gt; void f(T) {
      A&lt;T&gt; at;
      g(at, (T)0);
    }

    enum { e };

    void g(A&lt;decltype(e)&gt;, decltype(e)){}  // not allowed

    int main() {
      f(e);
    }
</PRE>

<P>These deficiencies could be addressed by allowing types without
linkage to be used as the type of a variable or function, but with
the requirement that any such entity that is used must also be
defined in the same translation unit.  This would allow issuing a
compile-time, instead of a link-time, diagnostic if the definition
were not provided, for example.  It also seems to be easier to
implement than the current rules.</P>

<BR><BR><HR><A NAME="759"></A><H4>759.
  
Destruction of closure objects
</H4><B>Section: </B>5.1.1&#160;
 [expr.prim.lambda]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>22 January, 2009<BR>




<P>The specification of closure objects is missing a couple of important
points regarding their destruction.  First, although 5.1.1
 [expr.prim.lambda]
paragraph 11 mentions other implicitly-declared special member functions,
it is silent on the destructor, leading to questions about whether the
closure class has one or not.</P>

<P>Second, nothing is said about the timing of the destruction of a
closure object: is it normally destroyed at the end of the full-expression
to which the lambda expression belongs, and is its lifetime extended if
the closure object is bound to a reference?  These questions would be
addressed if paragraph 2 defined the closure object as a temporary instead
of just as an rvalue.  (It should be noted that 5.2.3
 [expr.type.conv]
also does not define the conceptually-similar <TT>T()</TT> as a
temporary.)</P>

<BR><BR><HR><A NAME="761"></A><H4>761.
  
Inferred return type of closure object call operator
</H4><B>Section: </B>5.1.1&#160;
 [expr.prim.lambda]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

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


<P>According to 5.1.1
 [expr.prim.lambda] paragraph 10, the following
lambda expressions are ill-formed because the return types of the
generated <TT>operator()</TT> functions are an array type and a function
type, respectively:</P>

<PRE>
    void f() {
      []{ return ""; }
      []{ return f; }
    }
</PRE>

<P>It would seem reasonable to expect the array-to-pointer and
function-to-pointer decay to apply to these return values and
hence to the inferred return type of <TT>operator()</TT>.</P>

<BR><BR><HR><A NAME="762"></A><H4>762.
  
Name lookup in the <I>compound-statement</I> of a lambda expression
</H4><B>Section: </B>5.1.1&#160;
 [expr.prim.lambda]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

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


<P>The current wording of 5.1.1
 [expr.prim.lambda] is not clear as to
how name lookup is to be performed for names appearing in the
<I>compound-statement</I> of a lambda expression.  Consider, for
example:</P>

<PRE>
    int fac(int n) {
      return [=]{ return n &lt;= 1 ? 1 : n*operator()(n-1); }();
    }
</PRE>

<P>There is no <TT>operator()</TT> in scope in the context of the
lambda expression.  Consequently, according to bullet 5 of paragraph 10,
the reference to <TT>operator()</TT> is not transformed to the class
member access syntax but appears untransformed in the closure object's
function call operator, where presumably it is interpreted as a
recursive call to itself.</P>

<P>A similar question (although it does not involve name lookup per
se) arises with respect to use of <TT>this</TT> in the
<I>compound-statement</I> of a lambda expression that does not appear
in the body of a non-static member function; for example,</P>

<PRE>
    void f() {
      float v;
      [v]() { return v+this-&gt;v; }
    }
</PRE>

<P><TT>this</TT> cannot refer to anything except the closure object,
so are the two references to <TT>v</TT> equivalent?</P>

<P>The crux of this question is whether the lookups for names in the
<I>compound-statement</I> are done in the context of the lambda
expression or from the call operator of the closure object.  The note at
the end of paragraph 10 bullet 5 would tend to support the latter
interpretation:</P>

<BLOCKQUOTE>

[<I>Note:</I> Reference to captured variables or references within
the <I>compound-statement</I> refer to the data members of <TT>F</TT>.
&#8212;<I>end note</I>]

</BLOCKQUOTE>

<P>Another possible interpretation of the current wording is that
there are two distinct <I>compound-statement</I>s in view: the
<I>compound-statement</I> that is part of the <I>lambda-expression</I>
and the body of the closure object's function call operator that is
&#8220;obtained from&#8221; the former.  If this is the intended
interpretation, one way of addressing the issues regarding the
<TT>operator()</TT> example above would be to state that it is an
error if the lookup of a name in the <I>compound-statement</I> fails,
making the example ill-formed.</P>

<BR><BR><HR><A NAME="763"></A><H4>763.
  
Is a closure object's <TT>operator()</TT> inline?
</H4><B>Section: </B>5.1.1&#160;
 [expr.prim.lambda]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>6 February, 2009<BR>


<P>A lambda expression appearing in local scope presumably creates a
local class (in the sense of 9.8
 [class.local]) as the type of the
closure object, because that class is &#8220;considered to be defined at
the point where the lambda expression occurs&#8221;
(5.1.1
 [expr.prim.lambda] paragraph 7), and in the absence of any
indication to the contrary that class must satisfy the restrictions of
9.8
 [class.local] on local classes.  One such restriction is that
all its member functions must be defined within the class definition,
making them inline.  However, nothing is said about whether the function
call operator for a non-local closure class is inline, and even for the
local case it would be better if the specification were explicit.
</P>

<BR><BR><HR><A NAME="764"></A><H4>764.
  
Capturing unused variables in a lambda expression
</H4><B>Section: </B>5.1.1&#160;
 [expr.prim.lambda]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Adamczyk
 &#160;&#160;&#160;

 <B>Date: </B>6 February, 2009<BR>


<P>5.1.1
 [expr.prim.lambda] paragraph 5 says,</P>

<BLOCKQUOTE>

 The <I>compound-statement</I> of a lambda expression shall use
(3.2
 [basic.def.odr]) an automatic variable or reference from the
context where the lambda expression appears only if the name of the
variable or reference is a member of the effective capture set...

</BLOCKQUOTE>

<P>The reference to 3.2
 [basic.def.odr] makes clear that the
technical meaning of &#8220;use&#8221; is in view here, and that the
names of variables can appear without being captured if they are
constants used as values or if they are unevaluated operands.</P>

<P>There appears to be a disconnect with the preceding paragraph,
however, in the description of which variables are implicitly
captured by a <I>capture-default</I>:</P>

<BLOCKQUOTE>

for each name <TT>v</TT> that appears in the lambda expression and denotes a
local variable or reference with automatic storage duration in the
context where the lambda expression appears and that does not appear
in the <I>capture-list</I> or as a parameter name in the
<I>lambda-parameter-declaration-list</I>...

</BLOCKQUOTE>

<P>It would be more consistent if only variables that were required by
paragraph 5 to be captured were implicitly captured, i.e., if
&#8220;that appears in the lambda expression&#8221; were replaced by
&#8220;that is used (3.2
 [basic.def.odr]) in the
<I>compound-statement</I> of the lambda expression.&#8221;  For
example,</P>

<PRE>
    struct A {
      A();
      A(const A&amp;);
      ~A();
    };
    void f() {
      A a;
      int i = [=]() { return sizeof a; }();
    }
</PRE>

<P>Here, <TT>a</TT> will be captured (and copied), even though it is
not &#8220;used&#8221; in the lambda expression.</P>

<BR><BR><HR><A NAME="766"></A><H4>766.
  
Where may lambda expressions appear?
</H4><B>Section: </B>5.1.1&#160;
 [expr.prim.lambda]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>6 February, 2009<BR>


<P>According to 5.1.1
 [expr.prim.lambda] paragraph 7, the appearance of
a lambda expression results in the definition of a class &#8220;considered
to be defined at the point where the lambda expression occurs.&#8221;  It
is not clear whether that means that a lambda expression cannot appear
at any point where it is not permitted to define a class type.  For
example, 8.3.5
 [dcl.fct] paragraph 10 says, &#8220;Types shall
not be defined in return or parameter types.&#8221;  Does that mean that
a function declaration like</P>

<PRE>
    void f(int a[sizeof ([]{ return 0; })]);
</PRE>

<P>is ill-formed, because the parameter type defines the closure class
for the lambda expression? (<A HREF="
     cwg_defects.html#686">Issue 686</A> lists
many contexts in which type definitions are prohibited.  Each of these
should be examined to see whether a lambda expression should be allowed
or prohibited there.)</P>

<BR><BR><HR><A NAME="722"></A><H4>722.
  
Can <TT>nullptr</TT> be passed to an ellipsis?
</H4><B>Section: </B>5.2.2&#160;
 [expr.call]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alisdair Meredith
 &#160;&#160;&#160;

 <B>Date: </B>25 September, 2008<BR>


<P>The current wording of 5.2.2
 [expr.call] paragraph 7 is:</P>

<BLOCKQUOTE>

After these conversions, if the argument does not have
arithmetic, enumeration, pointer, pointer to member, or effective
class type, the program is ill-formed.

</BLOCKQUOTE>

<P>It's not clear whether this is intended to exclude anything other
than <TT>void</TT>, but the effect is to disallow passing
<TT>nullptr</TT> to ellipsis.  That seems unnecessary.</P>

<BR><BR><HR><A NAME="731"></A><H4>731.
  
Omitted reference qualification of member function type
</H4><B>Section: </B>5.2.5&#160;
 [expr.ref]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daniel Kr&#252;gler
 &#160;&#160;&#160;

 <B>Date: </B>6 October, 2008<BR>




<P>There are several places in the Standard that were overlooked when
reference qualification of member functions was added.  For example,
5.2.5
 [expr.ref] paragraph 4, bullet 3, sub-bullet 2 says,</P>

<BLOCKQUOTE>

...if <TT>E1.E2</TT> refers to a non-static member function, and the
type of <TT>E2</TT> is &#8220;function of parameter-type-list
<I>cv</I> returning <TT>T</TT>&#8221;, then...

</BLOCKQUOTE>

<P>This wording incorrectly excludes member functions declared with a
<I>ref-qualifier</I>.</P>

<P>Another place that should consider reference qualification is
5.5
 [expr.mptr.oper]; it should not be possible to invoke an
&amp;-qualified member function with an rvalue object expression.</P>

<P>A third place is 7.3.3
 [namespace.udecl] paragraph 15, which
does not mention reference qualification in connection with the
hiding/overriding of member functions brought in from a base class
via a <I>using-declaration</I>.</P>

<BR><BR><HR><A NAME="742"></A><H4>742.
  
Postfix increment/decrement with long bit-field operands
</H4><B>Section: </B>5.2.6&#160;
 [expr.post.incr]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>11 November, 2008<BR>


<P>Given the following declarations:</P>

<PRE>
    struct S {
        signed long long sll2: 3;
    };
    S s = { -1 };
</PRE>

<P>the expressions <TT>s.sll-- &lt; 0u</TT> and <TT>s.sll &lt; 0u</TT>
have different results.  The reason for this is that <TT>s.sll--</TT>
is an rvalue of type <TT>signed long long</TT> (5.2.6
 [expr.post.incr]), which means that the usual arithmetic conversions
(5
 [expr] paragraph 10) convert <TT>0u</TT> to
<TT>signed long long</TT> and the result is <TT>true</TT>.
<TT>s.sll</TT>, on the other hand, is a bit-field lvalue, which is
promoted (4.5
 [conv.prom] paragraph 3) to <TT>int</TT>; both
operands of <TT>&lt;</TT> have the same rank, so <TT>s.sll</TT> is
converted to <TT>unsigned int</TT> to match the type of <TT>0u</TT>
and the result is <TT>false</TT>.  This disparity seems
undesirable.</P>

<BR><BR><HR><A NAME="282"></A><H4>282.
  
Namespace for <TT>extended_type_info</TT>
</H4><B>Section: </B>5.2.8&#160;
 [expr.typeid]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jens Maurer
 &#160;&#160;&#160;

 <B>Date: </B>01 May 2001<BR>


<P>The original proposed resolution for <A HREF="
     cwg_defects.html#160">issue 160</A>
included changing <TT>extended_type_info</TT>
(5.2.8
 [expr.typeid] paragraph 1, footnote 61) to
<TT>std::extended_type_info</TT>.  There was no consensus on whether
this name ought to be part of namespace <TT>std</TT> or in a
vendor-specific namespace, so the question was moved into a
separate issue.</P>

<BR><BR><HR><A NAME="528"></A><H4>528.
  
Why are incomplete class types not allowed with <TT>typeid</TT>?
</H4><B>Section: </B>5.2.8&#160;
 [expr.typeid]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Dave Abrahams
 &#160;&#160;&#160;

 <B>Date: </B>18 May 2005<BR>




<P>5.2.8
 [expr.typeid] paragraph 4 says,</P>

<BLOCKQUOTE>

When <TT>typeid</TT> is applied to a <I>type-id</I>, the result refers
to a <TT>std::type_info</TT> object representing the type of
the <I>type-id</I>.  If the type of the <I>type-id</I> is a reference
type, the result of the <TT>typeid</TT> expression refers to
a <TT>std::type_info</TT> object representing the referenced type. If
the type of the <I>type-id</I> is a class type or a reference to a
class type, the class shall be completely-defined.

</BLOCKQUOTE>

<P>I'm wondering whether this is not overly restrictive.  I can't
think of a reason to require that <TT>T</TT> be completely-defined
in <TT>typeid(T)</TT> when <TT>T</TT> is a class type.  In fact,
several popular compilers enforce that restriction
for <TT>typeid(T)</TT>, but not for <TT>typeid(T&amp;)</TT>.  Can
anyone explain this?
</P>

<P><U>Nathan Sidwell</U>: I think this restriction is so that whenever
the compiler has to emit a typeid object of a class type, it knows
what the base classes are, and can therefore emit an array of
pointers-to-base-class typeids.  Such a tree is necessary to implement
<TT>dynamic_cast</TT> and exception catching (in a commonly
implemented and obvious manner).  If the class could be incomplete,
the compiler might have to emit a typeid for incomplete <TT>Foo</TT>
in one object file and a typeid for complete <TT>Foo</TT> in another
object file.  The compilation system will then have to make sure that
(a) those compare equal and (b) the complete <TT>Foo</TT> gets
priority, if that is applicable.
</P>

<P>Unfortunately, there is a problem with exceptions that means there
still can be a need to emit typeids for incomplete class.  Namely one
can throw a pointer-to-pointer-to-incomplete.  To implement the
matching of pointer-to-derived being caught by pointer-to-base, it is
necessary for the typeid of a pointer type to contain a pointer to the
typeid of the pointed-to type.  In order to do the qualification
matching on a multi-level pointer type, one has a chain of pointer
typeids that can terminate in the typeid of an incomplete type.  You
cannot simply NULL-terminate the chain, because one must distinguish
between different incomplete types.</P>

<P><U>Dave Abrahams</U>: So if implementations are still required to
be able to do it, for all practical purposes, why aren't we letting
the user have the benefits?</P>

<P><B>Notes from the April, 2006 meeting:</B></P>

<P>There was some concern expressed that this might be difficult under
the IA64 ABI.  It was also observed that while it is necessary to
handle exceptions involving incomplete types, there is no requirement
that the RTTI data structures be used for exception handling.</P>

<BR><BR><HR><A NAME="734"></A><H4>734.
  
Are unique addresses required for namespace-scope variables?
</H4><B>Section: </B>5.2.10&#160;
 [expr.reinterpret.cast]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>15 October, 2008<BR>


<P>Consider the following example:</P>

<PRE>
    static const char test1 = 'x';
    static const char test2 = 'x';
    bool f() {
        return &amp;test1 != &amp;test2;
    }
</PRE>

<P>Is <TT>f()</TT> allowed to return <TT>false</TT>?  Can a smart
optimizer alias these two variables, taking advantage of the fact that
they are <TT>const</TT>, initialized to the same value, and thus can
never be different in a well-defined program?</P>

<P>The C++ Standard doesn't explicitly specify address allocation of
objects except as members of arrays and classes, so the answer would
appear to be that such an implementation would be conforming.</P>

<P>This situation appears to have been the inadvertent result of
the resolution of <A HREF="
     cwg_defects.html#73">issue 73</A>. Prior to that
change, 5.10
 [expr.eq] said,</P>

<BLOCKQUOTE>

Two pointers of the same type compare equal if and only if they...
both point to the same object...

</BLOCKQUOTE>

<P>That resolution introduced the current wording,</P>

<BLOCKQUOTE>

Two pointers of the same type compare equal if and only if... both
represent the same address.

</BLOCKQUOTE>

<BR><BR><HR><A NAME="203"></A><H4>203.
  
Type of address-of-member expression
</H4><B>Section: </B>5.3.1&#160;
 [expr.unary.op]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Lisa Lippincott
 &#160;&#160;&#160;

 <B>Date: </B>8 Feb 2000<BR>



<P>5.3.1
 [expr.unary.op]
 paragraph 2 indicates
that the type of an address-of-member expression reflects the class in
which the member was declared rather than the class identified in the
<I>nested-name-specifier</I> of the <I>qualified-id</I>.  This
treatment is unintuitive and can lead to strange code and unexpected
results.  For instance, in</P>

<PRE>
    struct B { int i; };
    struct D1: B { };
    struct D2: B { };

    int (D1::* pmD1) = &amp;D2::i;   // NOT an error
</PRE>

More seriously, template argument deduction can give surprising
results:

<PRE>
    struct A {
       int i;
       virtual void f() = 0;
    };

    struct B : A {
       int j;
       B() : j(5)  {}
       virtual void f();
    };

    struct C : B {
       C() { j = 10; }
    };

    template &lt;class T&gt;
    int DefaultValue( int (T::*m) ) {
       return T().*m;
    }

    ... DefaultValue( &amp;B::i )    // Error: A is abstract
    ... DefaultValue( &amp;C::j )    // returns 5, not 10.
</PRE>

<P><B>Suggested resolution:</B>
5.3.1
 [expr.unary.op]
 should be changed to
read,</P>

<BLOCKQUOTE>
If the member is a nonstatic member (perhaps by inheritance) of the
class nominated by the <I>nested-name-specifier</I> of the
<I>qualified-id</I> having type <TT>T</TT>, the type of the result is
"pointer to member of class <I>nested-name-specifier</I> of type
<TT>T</TT>."
</BLOCKQUOTE>

and the comment in the example should be changed to read,

<BLOCKQUOTE>
<TT>// <I>has type </I>int B::*</TT>
</BLOCKQUOTE>

<P><B>Notes from 04/00 meeting:</B></P>

<P>The rationale for the current treatment is to permit the widest
possible use to be made of a given address-of-member expression.
Since a pointer-to-base-member can be implicitly converted to a
pointer-to-derived-member, making the type of the expression a
pointer-to-base-member allows the result to initialize or be assigned
to either a pointer-to-base-member or a pointer-to-derived-member.
Accepting this proposal would allow only the latter use.</P>

<P><B>Additional notes:</B></P>

<P>Another problematic example has been mentioned:</P>

<PRE>
    class Base {
    public:
      int func() const;
    };

    class Derived : public Base {
    };

    template&lt;class T&gt;
    class Templ {
    public:
      template&lt;class S&gt;
      Templ(S (T::*ptmf)() const);
    };

    void foo()
    {
      Templ&lt;Derived&gt; x(&amp;Derived::func);    // <I>ill-formed</I>
    }
</PRE>

<P>In this example, even though the conversion of
<TT>&amp;Derived::func</TT> to <TT>int (Derived::*)() const</TT> is
permitted, the initialization of <TT>x</TT> cannot be done because
template argument deduction for the constructor fails.</P>

<P>If the suggested resolution were adopted, the amount of code broken
by the change might be reduced by adding an implicit conversion from
pointer-to-derived-member to pointer-to-base-member for appropriate
address-of-member expressions (not for arbitrary pointers to members,
of course).</P>

<P>(See also <A HREF="
     cwg_closed.html#247">issue 247</A>.)</P>

<BR><BR><HR><A NAME="267"></A><H4>267.
  
Alignment requirement for <I>new-expression</I>s
</H4><B>Section: </B>5.3.4&#160;
 [expr.new]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Kuyper
 &#160;&#160;&#160;

 <B>Date: </B>4 Dec 2000<BR>


<P>Requirements for the alignment of pointers returned by
<I>new-expression</I>s are given in 5.3.4
 [expr.new]
paragraph 10:</P>

<BLOCKQUOTE>

For arrays of <TT>char</TT> and <TT>unsigned char</TT>, the difference
between the result of the <I>new-expression</I> and the address
returned by the allocation function shall be an integral multiple of
the most stringent alignment requirement (3.9
 [basic.types])
of any object type whose size is no greater than the size of the array
being created.

</BLOCKQUOTE>

<P>The intent of this wording is that the pointer returned by the
<I>new-expression</I> will be suitably aligned for any data type
that might be placed into the allocated storage (since the
allocation function is constrained to return a pointer to
maximally-aligned storage).  However, there is an implicit
assumption that each alignment requirement is an integral multiple
of all smaller alignment requirements.  While this is probably a
valid assumption for all real architectures, there's no reason
that the Standard should require it.</P>

<P>For example, assume that <TT>int</TT> has an alignment requirement
of 3 bytes and <TT>double</TT> has an alignment requirement of 4
bytes.  The current wording only requires that a buffer that is big
enough for an <TT>int</TT> or a <TT>double</TT> be aligned on a 4-byte
boundary (the more stringent requirement), but that would allow the
buffer to be allocated on an 8-byte boundary &#8212; which might
<I>not</I> be an acceptable location for an <TT>int</TT>.</P>

<P><U>Suggested resolution</U>: Change "of any object type" to
"of every object type."</P>

<P>A similar assumption can be found in
5.2.10
 [expr.reinterpret.cast] paragraph 7:</P>

<BLOCKQUOTE>

...converting an rvalue of type "pointer to <TT>T1</TT>" to the type
"pointer to <TT>T2</TT>" (where ... the alignment requirements of
<TT>T2</TT> are no stricter than those of <TT>T1</TT>) and back to its
original type yields the original pointer value...

</BLOCKQUOTE>

<P><U>Suggested resolution</U>: Change the wording to</P>

<BLOCKQUOTE>

...converting an rvalue of type "pointer to <TT>T1</TT>" to the type
"pointer to <TT>T2</TT>" (where ...  the alignment requirements of
<B><TT>T1</TT> are an integer multiple of those of <TT>T2</TT></B>)
and back to its original type yields the original pointer value...

</BLOCKQUOTE>

<P>The same change would also be needed in paragraph 9.</P>

<BR><BR><HR><A NAME="473"></A><H4>473.
  
Block-scope declarations of allocator functions
</H4><B>Section: </B>5.3.4&#160;
 [expr.new]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>12 Jul 2004<BR>


<P>Looking up <TT>operator new</TT> in a <I>new-expression</I>
uses a different mechanism from ordinary lookup.  According to
5.3.4
 [expr.new] paragraph 9,</P>

<BLOCKQUOTE>
If the <I>new-expression</I> begins with a unary <TT>::</TT>
operator, the allocation function's name is looked up in the
global scope. Otherwise, if the allocated type is a class type
<TT>T</TT> or array thereof, the allocation function's name is
looked up in the scope of <TT>T</TT>. If this lookup fails to
find the name, or if the allocated type is not a class type, the
allocation function's name is looked up in the global scope.
</BLOCKQUOTE>

<P>Note in particular that the scope in which the
<I>new-expression</I> occurs is not considered.  For example,</P>

<PRE>
    void f() {
        void* operator new(std::size_t, void*);
        int* i = new int;    // okay?
    }
</PRE>

<P>In this example, the implicit reference to <TT>operator
new(std::size_t)</TT> finds the global declaration, even though
the block-scope declaration of <tt>operator new</tt> with a
different signature would hide it from an ordinary reference.</P>

<P>This seems strange; either the block-scope declaration should
be ill-formed or it should be found by the lookup.</P>

<P><B>Notes from October 2004 meeting:</B></P>

<P>The CWG agreed that the block-scope declaration should not be
found by the lookup in a <I>new-expression</I>.  It would,
however, be found by ordinary lookup if the allocation function
were invoked explicitly.</P>

<BR><BR><HR><A NAME="476"></A><H4>476.
  
Determining the buffer size for placement new
</H4><B>Section: </B>5.3.4&#160;
 [expr.new]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Ben Hutchings
 &#160;&#160;&#160;

 <B>Date: </B>14 Sep 2004<BR>


<P>(See also <A HREF="
     cwg_defects.html#256">issue 256</A>.)</P>

<P>An implementation may have an unspecified amount of array
allocation overhead (5.3.4
 [expr.new] paragraph 10),
so that evaluation of a <I>new-expression</I> in which the
<I>new-type-id</I> is <TT>T[n]</TT> involves a request for more
than <TT>n * sizeof(T)</TT> bytes of storage through the relevant
<TT>operator new[]</TT> function.</P>

<P>The placement <TT>operator new[]</TT> function does not and
cannot check whether the requested size is less than or equal to
the size of the provided region of memory (18.5.1.3
 [new.delete.placement] paragraphs 5-6).  A program using placement
array new must calculate what the requested size will be in
advance.</P>

<P>Therefore any program using placement array new must take into
account the implementation's array allocation overhead, which
cannot be obtained or calculated by any portable means.</P>

<P><B>Notes from the April, 2005 meeting:</B></P>

<P>While the CWG agreed that there is no portable means to
accomplish this task in the current language, they felt that a
paper is needed to analyze the numerous mechanisms that might
address the problem and advance a specific proposal.  There is
no volunteer to write such a paper at this time.</P>

<BR><BR><HR><A NAME="196"></A><H4>196.
  
Arguments to deallocation functions </H4><B>Section: </B>5.3.5&#160;
 [expr.delete]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Matt Austern
 &#160;&#160;&#160;

 <B>Date: </B>20 Jan 2000<BR>





<P>5.3.4
 [expr.new]
 paragraph 10 says that
the result of an array allocation function and the value of the array
<I>new-expression</I> from which it was invoked may be different,
allowing for space preceding the array to be used for implementation
purposes such as saving the number of elements in the array.  However,
there is no corresponding description of the relationship between the
operand of an array <I>delete-expression</I> and the argument passed
to its deallocation function.</P>

<P>3.7.4.2
 [basic.stc.dynamic.deallocation]

paragraph 3 does state that</P>

<BLOCKQUOTE>
the value supplied to <TT>operator delete[](void*)</TT> in the
standard library shall be one of the values returned by a previous
invocation of either <TT>operator new[](std::size_t)</TT> or
<TT>operator new[](std::size_t, const std::nothrow_t&amp;)</TT> in the
standard library.
</BLOCKQUOTE>

<P>This statement might be read as requiring an implementation, when
processing an array <I>delete-expression</I> and calling the
deallocation function, to perform the inverse of the calculation
applied to the result of the allocation function to produce the value
of the <I>new-expression</I>.
(5.3.5
 [expr.delete]
 paragraph 2 requires
that the operand of an array <I>delete-expression</I> "be the pointer
value which resulted from a previous array <I>new-expression</I>.")
However, it is not completely clear whether the "shall" expresses an
implementation requirement or a program requirement (or both).
Furthermore, there is no direct statement about user-defined
deallocation functions.</P>

<P><B>Suggested resolution:</B> A note should be added to
5.3.5
 [expr.delete]
 to clarify that any
offset added in an array <I>new-expression</I> must be subtracted in
the array <I>delete-expression</I>.</P>
<BR><BR><HR><A NAME="242"></A><H4>242.
  
Interpretation of old-style casts
</H4><B>Section: </B>5.4&#160;
 [expr.cast]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>30 Aug 2000<BR>




<P>The meaning of an old-style cast is described in terms of
<TT>const_cast</TT>, <TT>static_cast</TT>, and
<TT>reinterpret_cast</TT> in 5.4
 [expr.cast] paragraph 5.
Ignoring <TT>const_cast</TT> for the moment, it basically says that if
the conversion performed by a given old-style cast is one of those
performed by <TT>static_cast</TT>, the conversion is interpreted as if
it were a <TT>static_cast</TT>; otherwise, it's interpreted as if it
were a <TT>reinterpret_cast</TT>, if possible.  The following example
is given in illustration:</P>

<PRE>
    struct A {};
    struct I1 : A {};
    struct I2 : A {};
    struct D : I1, I2 {};
    A *foo( D *p ) {
	return (A*)( p ); // ill-formed static_cast interpretation
    }
</PRE>

<P>The obvious intent here is that a derived-to-base pointer
conversion is one of the conversions that can be performed using
<TT>static_cast</TT>, so <TT>(A*)(p)</TT> is equivalent to
<TT>static_cast&lt;A*&gt;(p)</TT>, which is ill-formed because of the
ambiguity.</P>

<P>Unfortunately, the description of <TT>static_cast</TT> in
5.2.9
 [expr.static.cast] does NOT support this interpretation.
The problem is in the way 5.2.9
 [expr.static.cast] lists the
kinds of casts that can be performed using <TT>static_cast</TT>.
Rather than saying something like "All standard conversions can be
performed using <TT>static_cast</TT>," it says</P>

<BLOCKQUOTE>
An expression e can be explicitly converted to a type <TT>T</TT> using
a <TT>static_cast</TT> of the form <TT>static_cast&lt;T&gt;(e)</TT> if
the declaration "<TT>T t(e);</TT>" is well-formed, for some invented
temporary variable <TT>t</TT>.
</BLOCKQUOTE>

<P>Given the declarations above, the hypothetical declaration</P>

<PRE>
    A* t(p);
</PRE>

<P>is NOT well-formed, because of the ambiguity.  Therefore the old-style
cast <TT>(A*)(p)</TT> is NOT one of the conversions that can be performed
using <TT>static_cast</TT>, and <TT>(A*)(p)</TT> is equivalent to
<TT>reinterpret_cast&lt;A*&gt;(p)</TT>, which is well-formed under
5.2.10
 [expr.reinterpret.cast] paragraph 7.</P>

<P>Other situations besides ambiguity which might raise similar
questions include access violations, casting from virtual base
to derived, and casting pointers-to-members when virtual
inheritance is involved.</P>

<BR><BR><HR><A NAME="583"></A><H4>583.
  
Relational pointer comparisons against the null pointer constant
</H4><B>Section: </B>5.9&#160;
 [expr.rel]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Widman
 &#160;&#160;&#160;

 <B>Date: </B>24 May 2006<BR>




<P>In C, this is ill-formed (cf C99 6.5.8):</P>

<PRE>
    void f(char* s) {
        if (s &lt; 0) { }
    }
</PRE>

<P>...but in C++, it's not.  Why?  Who would ever need to write
<TT>(s &gt; 0)</TT>
when they could just as well write <TT>(s != 0)</TT>?</P>

<P>This has been in the language since the ARM (and possibly earlier);
apparently it's because the pointer conversions (4.10
 [conv.ptr]) need to be performed on both operands whenever one of
the operands is of pointer type.  So it looks like the
"null-ptr-to-real-pointer-type" conversion is hitching a ride with the
other pointer conversions.</P>

<BR><BR><HR><A NAME="715"></A><H4>715.
  
Class member access constant expressions
</H4><B>Section: </B>5.19&#160;
 [expr.const]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Adamczyk
 &#160;&#160;&#160;

 <B>Date: </B>17 September, 2008<BR>


<P>Bullet 12 of paragraph 2 of 5.19
 [expr.const] says,</P>

<UL><LI><P>a class member access (5.2.5
 [expr.ref])
unless its <I>postfix-expression</I> is of effective literal type
or of pointer to effective literal type;</P></LI></UL>

<P>This wording needs to be clearer that the &#8220;effective
literal type&#8221; provision applies only to the <TT>.</TT>
form of member access and the &#8220;pointer to effective
literal type&#8221; applies only to the <TT>-&gt;</TT> form.</P>

<BR><BR><HR><A NAME="721"></A><H4>721.
  
Where must a variable be initialized to be used in a constant expression?
</H4><B>Section: </B>5.19&#160;
 [expr.const]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Kanze
 &#160;&#160;&#160;

 <B>Date: </B>22 September, 2008<BR>




<P>5.19
 [expr.const] paragraph 2 allows an
lvalue-to-rvalue conversion in a constant expression if it is
applied to &#8220;an lvalue of effective integral type that
refers to a non-volatile const variable or static data member
initialized with constant expressions.&#8221;  However, this
does not require, as it presumably should, that the
initialization occur in the same translation unit and precede
the constant expression, nor that the static data member be
initialized within the <I>member-specification</I> of its
class.</P>

<P><U>Jens Maurer</U>: A comprehensive rewrite of this
sub-bullet would probably read:</P>

<UL><LI><P>an lvalue of effective integral type that refers to a
non-volatile const variable <B>with a preceding
initialization</B> or <B>to a non-volatile const</B> static data
member <B>with an initialization in the class definition
(9.4.2
 [class.static.data]), in either case</B> initialized with
constant expressions, or</P></LI></UL>

<BR><BR><HR><A NAME="631"></A><H4>631.
  
Jumping into a &#8220;then&#8221; clause
</H4><B>Section: </B>6.4.1&#160;
 [stmt.if]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Kanze
 &#160;&#160;&#160;

 <B>Date: </B>24 April 2007<BR>


<P>6.4.1
 [stmt.if] is silent about whether the <TT>else</TT>
clause of an <TT>if</TT> statement is executed if the condition is not
evaluated.  (This could occur via a <TT>goto</TT> or a <TT>longjmp</TT>.)
C99 covers the <TT>goto</TT> case with the following provision:</P>

<BLOCKQUOTE>

If the first substatement is reached via a label, the second
substatement is not executed.

</BLOCKQUOTE>

<P>It should probably also be stated that the condition is not
evaluated when the &#8220;then&#8221; clause is entered directly.</P>

<BR><BR><HR><A NAME="723"></A><H4>723.
  
Archetypes in skipped declarations
</H4><B>Section: </B>6.7&#160;
 [stmt.dcl]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Doug Gregor
 &#160;&#160;&#160;

 <B>Date: </B>3 October, 2008<BR>


<P>Paper N2762 changed 6.7
 [stmt.dcl] paragraph 3 from</P>

<BLOCKQUOTE>

...unless the variable has trivial type (3.9
 [basic.types])...

</BLOCKQUOTE>

<P>to</P>

<BLOCKQUOTE>

...unless the variable has scalar type, class type with a trivial
default constructor and a trivial destructor, a cv-qualified
version of one of these types, or an array of one of the preceding
types...

</BLOCKQUOTE>

<P>However, this change overrode the colliding change from
N2773 that would have changed it to read</P>

<BLOCKQUOTE>

...unless the variable has effective trivial type...

</BLOCKQUOTE>

<P>The revised wording needs to be changed to allow for
archetypes with the appropriate requirements.</P>

<BR><BR><HR><A NAME="157"></A><H4>157.
  
Omitted typedef declarator
</H4><B>Section: </B>7&#160;
 [dcl.dcl]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>19 Aug 1999<BR>





<P>7
 [dcl.dcl]
 paragraph 3 reads,</P>

<BLOCKQUOTE>
In a <I>simple-declaration</I>, the optional
<I>init-declarator-list</I> can be omitted only when... the
<I>decl-specifier-seq</I> contains either a <I>class-specifier</I>,
an <I>elaborated-type-specifier</I> with a <I>class-key</I>
(9.1
 [class.name]
), or an
<I>enum-specifier</I>.  In these cases and whenever a
<I>class-specifier</I> or <I>enum-specifier</I> is present in the
<I>decl-specifier-seq</I>, the identifiers in those specifiers are
among the names being declared by the declaration...  In such cases,
and except for the declaration of an unnamed bit-field
(9.6
 [class.bit]
), the
<I>decl-specifier-seq</I> shall introduce one or more names into the
program, or shall redeclare a name introduced by a previous
declaration.  [<I>Example:</I>

<PRE>
    enum { };           // <I>ill-formed</I>
    typedef class { };  // <I>ill-formed</I>
</PRE>

<I>&#8212;end example</I>]
</BLOCKQUOTE>

In the absence of any explicit restrictions in
7.1.3
 [dcl.typedef]
, this paragraph appears
to allow declarations like the following:

<PRE>
    typedef struct S { };    // no declarator
    typedef enum { e1 };     // no declarator
</PRE>

In fact, the final example in
7
 [dcl.dcl]
 paragraph 3 would seem to
indicate that this is intentional: since it is illustrating the
requirement that the <I>decl-specifier-seq</I> must introduce a name
in declarations in which the <I>init-declarator-list</I> is omitted,
presumably the addition of a class name would have made the example
well-formed.

<P>On the other hand, there is no good reason to allow such
declarations; the only reasonable scenario in which they might occur
is a mistake on the programmer's part, and it would be a service to
the programmer to require that such errors be diagnosed.</P>
<BR><BR><HR><A NAME="498"></A><H4>498.
  
Storage class specifiers in definitions of class members
</H4><B>Section: </B>7.1.1&#160;
 [dcl.stc]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Matt Austern
 &#160;&#160;&#160;

 <B>Date: </B>13 Jan 2005<BR>




<P>Suppose we've got this class definition:</P>

<PRE>
    struct X {
       void f();
       static int n;
    };
</PRE>

<P>I think I can deduce from the existing standard that the following 
member definitions are ill-formed:</P>

<PRE>
    static void X::f() { }
    static int X::n;
</PRE>

<P>To come to that conclusion, however, I have to put together several
things in different parts of the standard.  I would have expected to
find an explicit statement of this somewhere; in particular, I would
have expected to find it in 7.1.1
 [dcl.stc].  I don't
see it there, or anywhere.</P>

<P><U>Gabriel Dos Reis</U>: Or in 3.5
 [basic.link] which is
about linkage.  I would have expected that paragraph to say that that
members of class types have external linkage when the enclosing class
has an external linkage.  Otherwise 3.5
 [basic.link]
paragraph 8:
</P>

<BLOCKQUOTE>

Names not covered by these rules have no linkage.

</BLOCKQUOTE>

<P>might imply that such members do not have linkage.</P>

<P><B>Notes from the April, 2005 meeting:</B></P>

<P>The question about the linkage of class members is already
covered by 3.5
 [basic.link] paragraph 5.</P>

<BR><BR><HR><A NAME="717"></A><H4>717.
  
Unintentional restrictions on the use of <TT>thread_local</TT>
</H4><B>Section: </B>7.1.1&#160;
 [dcl.stc]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Clark Nelson
 &#160;&#160;&#160;

 <B>Date: </B>17 September, 2008<BR>


<P>The current wording unintentionally restricts the use of the
<TT>thread_local</TT> specifier in two contexts: block-scope
extern variable declarations and static data members.  These
restrictions are in conflict with 7.1.1
 [dcl.stc]
paragraph 1.</P>

<P>Suggested resolution:</P>

<P>Change 7.1.1
 [dcl.stc] paragraph 4 as follows:</P>

<BLOCKQUOTE>

The <TT>thread_local</TT> specifier shall be applied only to the
names of objects or references of namespace scope<B>, to the
names of objects or references that are static members of class
scope,</B> and to the names of objects or references of block
scope that also specify <B><TT>extern</TT> or</B>
<TT>static</TT>. It specifies that the named object or reference
has thread storage duration (3.7.3
 [basic.stc.auto]).

</BLOCKQUOTE>

<BR><BR><HR><A NAME="765"></A><H4>765.
  
Local types in inline functions with external linkage
</H4><B>Section: </B>7.1.2&#160;
 [dcl.fct.spec]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>6 February, 2009<BR>


<P>7.1.2
 [dcl.fct.spec] paragraph 4 specifies that local static
variables and string literals appearing in the body of an inline
function with external linkage must be the same entities in every
translation unit in the program.  Nothing is said, however, about
whether local types are likewise required to be the same.</P>

<P>Although a conforming program could always have determined this
by use of <TT>typeid</TT>, recent changes to C++ (allowing local types
as template type arguments, lambda expression closure classes) make this
question more pressing.
</P>

<BR><BR><HR><A NAME="700"></A><H4>700.
  
Constexpr member functions of class templates
</H4><B>Section: </B>7.1.5&#160;
 [dcl.constexpr]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jens Maurer
 &#160;&#160;&#160;

 <B>Date: </B>27 June, 2008<BR>




<P>7.1.5
 [dcl.constexpr] paragraph 5 applies only to &#8220;the
instantiated template specialization of a constexpr function
template;&#8221; it should presumably apply to non-template member
functions of a class template, as well.</P>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>This question is more involved than it might appear.  For example,
a constexpr member function is implicitly <TT>const</TT>; if the
<TT>constexpr</TT> specifier is ignored, does that make the member
function non-const?  Also, should this provision apply only to
dependent expressions in the function?  Should it be an error if no
constexpr function can be instantiated from the template, along the
lines of the permission given in 14.6
 [temp.res] paragraph 8
for an implementation to diagnose a template definition from which no
valid specialization can be instantiated?</P>

<BR><BR><HR><A NAME="609"></A><H4>609.
  
What is a &#8220;top-level&#8221; cv-qualifier?
</H4><B>Section: </B>7.1.6.1&#160;
 [dcl.type.cv]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Dawn Perchik
 &#160;&#160;&#160;

 <B>Date: </B>5 November 2006<BR>


<P>The phrase &#8220;top-level cv-qualifier&#8221; is used numerous
times in the Standard, but it is not defined.  The phrase could be
misunderstood to indicate that the <TT>const</TT> in something like
<TT>const T&amp;</TT> is at the &#8220;top level,&#8221; because
where it appears is the highest level at which it is permitted:
<TT>T&amp; const</TT> is ill-formed.</P>

<BR><BR><HR><A NAME="144"></A><H4>144.
  
Position of <TT>friend</TT> specifier
</H4><B>Section: </B>7.1.6.3&#160;
 [dcl.type.elab]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>22 Jul 1999<BR>





<P>7.1.6.3
 [dcl.type.elab]
 paragraph 1 seems to
impose an ordering constraint on the elements of friend class
declarations.  However, the general rule is that declaration
specifiers can appear in any order.  Should</P>

<PRE>
    class C friend;
</PRE>

be well-formed?
<BR><BR><HR><A NAME="711"></A><H4>711.
  
<TT>auto</TT> with <I>braced-init-list</I>
</H4><B>Section: </B>7.1.6.4&#160;
 [dcl.spec.auto]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jason Merrill
 &#160;&#160;&#160;

 <B>Date: </B>27 August, 2008<BR>




<P>One effect of the initializer-list proposal is that now we
allow</P>

<PRE>
    auto x = { 1, 2, 3 };  //<SPAN STYLE="font-family:Times"><I> </I></SPAN>decltype(x)<SPAN STYLE="font-family:Times"><I> is </I></SPAN>std::initializer_list&lt;int&gt;
</PRE>

<P>but not</P>

<PRE>
    auto ar[3] = { 1, 2, 3 };  //<SPAN STYLE="font-family:Times"><I> ill-formed</I></SPAN>
</PRE>

<P>This seems unfortunate, as the code for the first could also
support the second.  Incidentally, I also failed to update the
text in 7.1.6.4
 [dcl.spec.auto] paragraph 3 which forbids
the use of <TT>auto</TT> with <I>braced-init-list</I>s, so
technically the first form above is currently ill-formed but has
defined semantics.
</P>

<P><U>Bjarne Stroustrup</U>:</P>

<P>Is this the thin edge of a wedge? How about</P>

<PRE>
    vector&lt;auto&gt; v = { 1, 2, 3 };
</PRE>

<P>and</P>

<PRE>
    template&lt;class T&gt; void f(vector&lt;T&gt;&amp; v);
    f({1, 2, 3 });
</PRE>

<P>(See also <A HREF="
     cwg_active.html#625">issue 625</A>.)</P>

<BR><BR><HR><A NAME="746"></A><H4>746.
  
Use of <TT>auto</TT> in <I>new-expression</I>s
</H4><B>Section: </B>7.1.6.4&#160;
 [dcl.spec.auto]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jason Merrill
 &#160;&#160;&#160;

 <B>Date: </B>18 November, 2008<BR>




<P>In listing the acceptable contexts in which the <TT>auto</TT>
specifier may appear, 7.1.6.4
 [dcl.spec.auto]) paragraph 4
mentions &#8220;the <I>type-specifier-seq</I> in a <I>new-type-id</I>&#8221;
but not the <I>type-id</I> in the parenthesized form; that is,
<TT>new auto (42)</TT> is well-formed but <TT>new (auto) (42)</TT> is
not.  This seems an unnecessary restriction, as well as contradicting
5.3.4
 [expr.new] paragraph 2:</P>

<BLOCKQUOTE>

If the <TT>auto</TT> <I>type-specifier</I> appears in the
<I>type-specifier-seq</I> of a <I>new-type-id</I> or <I>type-id</I> of
a <I>new-expression</I>...

</BLOCKQUOTE>

<BR><BR><HR><A NAME="673"></A><H4>673.
  
Injection of names from <I>elaborated-type-specifier</I>s in <TT>friend</TT> declarations
</H4><B>Section: </B>7.3.1.2&#160;
 [namespace.memdef]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>6 February, 2008<BR>


<P>7.3.1.2
 [namespace.memdef] paragraph 3 is intended to prevent
injection of names from <TT>friend</TT> declarations into the containing
namespace scope:</P>

<BLOCKQUOTE>

If a <TT>friend</TT> declaration in a non-local class first declares a
class or function the friend class or function is a member of the
innermost enclosing namespace. The name of the friend is not found by
unqualified lookup (3.4.1
 [basic.lookup.unqual]) or by qualified lookup
(3.4.3
 [basic.lookup.qual]) until a matching declaration is provided
in that namespace scope (either before or after the class definition
granting friendship).

</BLOCKQUOTE>

<P>However, this does not address names declared by
<I>elaborated-type-specifier</I>s that are part of the <TT>friend</TT>
declaration.  Are these names intended to be visibly injected?  For
example, is the following well-formed?</P>

<PRE>
    class A {
        friend class B* f();
    };
    B* bp;    //<SPAN STYLE="font-family:Times"><I> Is <TT>B</TT> visible here?</I></SPAN>
</PRE>

<P>Implementations differ in their treatment of this example: EDG
and MSVC++ 8.0 accept it, while g++ 4.1.1 rejects it.</P>

<BR><BR><HR><A NAME="36"></A><H4>36.
  
<I>using-declaration</I>s in multiple-declaration contexts
</H4><B>Section: </B>7.3.3&#160;
 [namespace.udecl]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Andrew Koenig
 &#160;&#160;&#160;

 <B>Date: </B>20 Aug 1998<BR>





<P>Section 7.3.3
 [namespace.udecl]
 paragraph 8 says:</P>
<BLOCKQUOTE>A <I>using-declaration</I> is a declaration and can therefore be used
repeatedly where (and only where) multiple declarations are allowed.</BLOCKQUOTE>
It contains the following example:
<PRE>
    namespace A {
            int i;
    }
    
    namespace A1 {
            using A::i;
            using A::i;             // OK: double declaration
    }
    
    void f()
    {
            using A::i;
            using A::i;             // error: double declaration
    }
</PRE>
However, if "<TT>using A::i;</TT>" is really a declaration, and not a definition, it is far from clear that repeating it should be an error in either context.
Consider:
<PRE>
    namespace A {
            int i;
            void g();
    }
    
    void f() {
            using A::g;
            using A::g;
    }
</PRE>
Surely the definition of f should be analogous to
<PRE>
    void f() {
            void g();
            void g();
    }
</PRE>
which is well-formed because "<TT>void g();</TT>" is a declaration and
not a definition.

<P>Indeed, if the double using-declaration for <TT>A::i</TT> is prohibited
in <TT>f</TT>, why should it be allowed in namespace <TT>A1</TT>?</P>

<P><B>Proposed Resolution (04/99):</B>

Change the comment "<TT>// error: double declaration</TT>" to
"<TT>// OK: double declaration</TT>".

(This should be reviewed against existing practice.)</P>

<P><B>Notes from 04/00 meeting:</B></P>

<P>The core language working group was unable to come to consensus
over what kind of declaration a <I>using-declaration</I> should
emulate.  In a straw poll, 7 members favored allowing
<I>using-declaration</I>s wherever a non-definition declaration could
appear, while 4 preferred to allow multiple <I>using-declaration</I>s
only in namespace scope (the rationale being that the permission for
multiple <I>using-declaration</I>s is primarily to support its use in
multiple header files, which are seldom included anywhere other than
namespace scope).  John Spicer pointed out that <TT>friend</TT>
declarations can appear multiple times in class scope and asked if
<I>using-declaration</I>s would have the same property under the "like
a declaration" resolution.</P>

<P>As a result of the lack of agreement, the issue was returned to
"open" status.  </P>

<P>See also issues
<A HREF="
     cwg_defects.html#56">56</A>, <A HREF="
     cwg_defects.html#85">85</A>,
and <A HREF="
     cwg_active.html#138">138</A>..</P>

<P><B>Additional notes (January, 2005):</B></P>

<P>Some related issues have been raised concerning the following
example (modified from a C++ validation suite test):</P>

<PRE>
    struct A
    {
        int i;
        static int j;
    };

    struct B : A { };
    struct C : A { };

    struct D : virtual B, virtual C
    {
        using B::i;
        using C::i;
        using B::j;
        using C::j;
    };
</PRE>

<P>Currently, it appears that the <I>using-declaration</I>s of
<TT>i</TT> are ill-formed, on the basis of 7.3.3
 [namespace.udecl] paragraph 10:</P>

<BLOCKQUOTE>

Since a <I>using-declaration</I> is a declaration, the
restrictions on declarations of the same name in the same
declarative region (3.3
 [basic.scope]) also apply to
<I>using-declaration</I>s.

</BLOCKQUOTE>

<P>Because the <I>using-declaration</I>s of <TT>i</TT> refer to
different objects, declaring them in the same scope is not
permitted under 3.3
 [basic.scope].  It might, however,
be preferable to treat this case as many other ambiguities are:
allow the declaration but make the program ill-formed if a name
reference resolves to the ambiguous declarations.</P>

<P>The status of the <I>using-declaration</I>s of <TT>j</TT>,
however, is less clear.  They both declare the same entity and
thus do not violate the rules of 3.3
 [basic.scope].
This might (or might not) violate the restrictions of
9.2
 [class.mem] paragraph 1:</P>

<BLOCKQUOTE>

Except when used to declare friends (11.4
 [class.friend])
or to introduce the name of a member of a base class into a
derived class (7.3.3
 [namespace.udecl], 11.3
 [class.access.dcl]), <I>member-declaration</I>s declare members of the
class, and each such member-declaration shall declare at least
one member name of the class. A member shall not be declared
twice in the <I>member-specification</I>, except that a nested
class or member class template can be declared and then later
defined.

</BLOCKQUOTE>

<P>Do the <I>using-declaration</I>s of <TT>j</TT> repeatedly
declare the same member?  Or is the preceding sentence an
indication that a <I>using-declaration</I> is not a declaration
of a member?</P>

<BR><BR><HR><A NAME="386"></A><H4>386.
  
Friend declaration of name brought in by using-declaration
</H4><B>Section: </B>7.3.3&#160;
 [namespace.udecl]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Herb Sutter
 &#160;&#160;&#160;

 <B>Date: </B>8 Oct 2002<BR>


<P>The following came up recently on comp.lang.c++.moderated (edited for
brevity):</P>
<PRE>
  namespace N1 {
    template&lt;typename T&gt; void f( T* x ) {
      // ... other stuff ...
      delete x;
    }
  }

  namespace N2 {
    using N1::f;

    template&lt;&gt; void f&lt;int&gt;( int* ); // A: ill-formed

    class Test {
      ~Test() { }
      friend void f&lt;&gt;( Test* x );   // B: ill-formed?
    };
  }
</PRE>
<P>I strongly suspect, but don't have standardese to prove, that the friend
declaration in line B is ill-formed. Can someone show me the text that
allows or disallows line B?</P>

<P>Here's my reasoning: Writing "using" to pull the name into namespace N2
merely allows code in N2 to use the name in a call without qualification
(per 7.3.3
 [namespace.udecl]).
But just as declaring a specialization must be done in the
namespace where the template really lives (hence line A is ill-formed), I
suspect that declaring a specialization as a friend must likewise be done
using the original namespace name, not obliquely through a "using". I see
nothing in 7.3.3
 [namespace.udecl]
that would permit this use. Is there?</P>

<P><U>Andrey Tarasevich</U>:
14.5.4
 [temp.friend] paragraph 2 seems to get pretty close:
"A friend declaration that is not a
template declaration and in which the name of the friend is an unqualified
'template-id' shall refer to a specialization of a function template
declared in the nearest enclosing namespace scope". </P>

<P><U>Herb Sutter</U>:
OK, thanks. Then the question in this is the word "declared" -- in
particular, we already know we cannot declare a specialization of a template
in any other namespace but the original one.</P>

<P><U>John Spicer</U>:
This seems like a simple question, but it isn't.</P>

<P>First of all, I don't think the standard comments on this usage one way 
or the other.</P>

<P>A similar example using a namespace qualified name is ill-formed based 
on 8.3
 [dcl.meaning] paragraph 1:</P>
<PRE>
  namespace N1 {
        void f();
  }

  namespace N2 {
        using N1::f;
        class A {
                friend void N2::f();
        };
  }
</PRE>

<P><A HREF="
     cwg_active.html#138">Core issue 138</A> deals with this example:</P>
<PRE>
  void foo();
  namespace A{
    using ::foo;
    class X{
      friend void foo();
    };
  }
</PRE>
<P>The proposed resolution (not yet approved) for
<A HREF="
     cwg_active.html#138">issue 138</A> is that the 
friend declares a new
foo that conflicts with the using-declaration and results in an error.</P>

<P>Your example is different than this though because the presence of the 
explicit argument list
means that this is not declaring a new f but is instead using a 
previously declared f.</P>

<P>One reservation I have about allowing the example is the desire to have 
consistent rules for all of the "declaration like" uses of template 
functions.   <A HREF="
     cwg_defects.html#275">Issue 275</A> (in DR status) addresses the
issue of unqualified names in explicit instantiation and explicit 
specialization declarations.
It requires that such declarations refer to templates from the namespace 
containing the
explicit instantiation or explicit specialization.  I believe this rule 
is necessary for those directives but is not really required for friend 
declarations -- but there is the consistency issue.</P>

<P><B>Notes from April 2003 meeting:</B></P>

<P>This is related to <A HREF="
     cwg_active.html#138">issue 138</A>.  John Spicer
is supposed to update his paper on this topic.  This is a new case
not covered in that paper.  We agreed that the B line should be
allowed.</P>

<BR><BR><HR><A NAME="565"></A><H4>565.
  
Conflict rules for <I>using-declaration</I>s naming function templates
</H4><B>Section: </B>7.3.3&#160;
 [namespace.udecl]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Paolo Carlini
 &#160;&#160;&#160;

 <B>Date: </B>9 March 2006<BR>




<P>The Standard does not appear to specify what happens for code like the
following:</P>

<PRE>
    namespace one {
      template&lt;typename T&gt; void fun(T);
    }

    using one::fun;

    template&lt;typename T&gt; void fun(T);
</PRE>

<P>7.3.3
 [namespace.udecl] paragraph 13 does not appear to apply
because it deals only with functions, not function templates:</P>

<BLOCKQUOTE>

If a function declaration in namespace scope or block scope has the
same name and the same parameter types as a function introduced by a
<I>using-declaration</I>, and the declarations do not declare the same
function, the program is ill-formed.

</BLOCKQUOTE>

<P><U>John Spicer</U>: For function templates I believe the rule
should be that if they have the same function type (parameter types
and return type) and have identical template parameter lists, the
program is ill-formed.</P>

<BR><BR><HR><A NAME="563"></A><H4>563.
  
Linkage specification for objects
</H4><B>Section: </B>7.5&#160;
 [dcl.link]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>8 March 2006<BR>


<P>It is not clear whether some of the wording in 7.5
 [dcl.link]
that applies only to function types and names ought also to apply to
object names.  In particular, paragraph 3 says,</P>

<BLOCKQUOTE>

Every implementation shall provide for linkage to functions written in
the C programming language, <TT>"C"</TT>, and linkage to C++
functions, <TT>"C++"</TT>.

</BLOCKQUOTE>

<P>Nothing is said about variable names, apparently meaning that
implementations need not provide C (or even C++!) linkage for
variable names.  Also, paragraph 5 says,</P>

<BLOCKQUOTE>

Except for functions with C++ linkage, a function declaration without
a linkage specification shall not precede the first linkage
specification for that function. A function can be declared without a
linkage specification after an explicit linkage specification has been
seen; the linkage explicitly specified in the earlier declaration is
not affected by such a function declaration.

</BLOCKQUOTE>

<P>There doesn't seem to be a good reason for these provisions not
to apply to variable names, as well.</P>

<BR><BR><HR><A NAME="736"></A><H4>736.
  
Is the <TT>&amp;</TT> <I>ref-qualifier</I> needed?
</H4><B>Section: </B>8&#160;
 [dcl.decl]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alberto Ganesh Barbati
 &#160;&#160;&#160;

 <B>Date: </B>16 October, 2008<BR>




<P>Do we really need the <TT>&amp;</TT> <I>ref-qualifier</I>?  We
could get the same behavior without it if we relaxed the restriction
on ref-qualified and non-ref-qualified overloads in the same set:</P>

<UL>
<TABLE WIDTH="85%">
<TR>
<TD>
<B>with the <TT>&amp;</TT> <I>ref-qualifier</I></B>
</TD>
<TD>
<B>without the <TT>&amp;</TT> <I>ref-qualifier</I></B>
</TD>
</TR>
<TR>
<TD>
<PRE>
    struct S {
      void f();
    };
</PRE>
</TD>
<TD>
<PRE>
    struct S {
      void f();
    };
</PRE>
</TD>
</TR>
<TR>
<TD><PRE>
    struct S {
      void f() &amp;;
    };

</PRE>
</TD>
<TD>
<PRE>
    struct S {
      void f();
      void f() &amp;&amp; = delete;
    };
</PRE>
</TD>
</TR>
<TR>
<TD>
<PRE>
    struct S {
      void f() &amp;&amp;;
    };
</PRE>
</TD>
<TD>
<PRE>
    struct S {
      void f() &amp;&amp;;
    };
</PRE>
</TD>
</TR>
<TR>
<TD>
<PRE>
    struct S {
      void f() &amp;;
      void f() &amp;&amp;;
    };
</PRE>
</TD>
<TD>
<PRE>
    struct S {
      void f();
      void f() &amp;&amp;;
    };
</PRE>
</TD>
</TR>
</TABLE>
</UL>

<P>The main objection I can see to this change is that we would lose
the notational convenience of the <TT>&amp;</TT> <I>ref-qualifier</I>,
which would need to be replaced by a pair of declarations.  We might
overcome this by still allowing a single <TT>&amp;</TT> on a function
(although it would not be a <I>ref-qualifier</I>) as a synonym to a
non-ref-qualified declaration plus a deleted ref-qualified declaration.
</P>

<P>The biggest asymmetry between the implicit object parameter and
regular parameters is not in reference binding but in type deduction.
Consider:</P>

<PRE>
    template &lt;class R, class C, class A&gt; void f(R (T::*p)(A));
</PRE>

<P>With these members:</P>

<PRE>
    struct S {
       void mv(std::string);
       void mr(std::string&amp;);
       void ml(std::string&amp;&amp;);
    };
</PRE>

<P>then</P>

<PRE>
    f(&amp;S::mv); // deduces A = string
    f(&amp;S::mr); // deduces A = string&amp;
    f(&amp;S::ml); // deduces A = string&amp;&amp;
</PRE>

<P>On the other hand, with these members:</P>

<PRE>
    struct S {
       void mv(std::string);
       void mr(std::string) &amp;;
       void ml(std::string) &amp;&amp;
    };
</PRE>

<P>then</P>

<PRE>
  f(&amp;S::mv); // deduces C = S
  f(&amp;S::mr); // illegal
  f(&amp;S::ml); // illegal
</PRE>

<P>To make template <TT>f</TT> work with any pointer to member
function, I need three overloads of <TT>f</TT>.  Add cv-qualifiers
and it's twelve overloads!</P>

<P>And then there is the interaction with concepts.  Consider this
type:</P>

<PRE>
    struct Value {
        Value&amp; operator=(const Value&amp;) &amp;;
    };
</PRE>

<P>Is it, say, <TT>Regular</TT>?  If so, will the following compile,
and what is the outcome?</P>

<PRE>
    template &lt;Regular T&gt; void f() {
      T() = T();
    }

    void g() {
      f&lt;Value&gt;();
    }
</PRE>

<P>If <TT>Value</TT> is not <TT>Regular</TT>, that is a good
motivation to avoid ever using <TT>&amp;</TT> <I>ref-qualifier</I>s
on <TT>operator=</TT> (and probably on any member functions).</P>

<P>If <TT>Value</TT> is <TT>Regular</TT>, then either
<TT>f&lt;Value&gt;()</TT> doesn't compile, violating one of the
principal motivations for concepts, or it calls <TT>Value::operator=</TT>
on an rvalue, which was explicitly prohibited.</P>

<BR><BR><HR><A NAME="504"></A><H4>504.
  
Should use of a reference in its own initializer require a diagnostic?
</H4><B>Section: </B>8.3.2&#160;
 [dcl.ref]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Bjarne Stroustrup
 &#160;&#160;&#160;

 <B>Date: </B>14 Apr 2005<BR>


<P> Split
off from <A HREF="
     cwg_active.html#453">issue 453</A>.</P>

<P>It is in general not possible to determine at compile time whether
a reference is used before it is initialized.  Nevertheless, there is
some sentiment to require a diagnostic in the obvious cases that can
be detected at compile time, such as the name of a reference appearing
in its own initializer.  The resolution of <A HREF="
     cwg_active.html#453">issue 453</A> originally made such uses ill-formed, but the CWG decided
that this question should be a separate issue.</P>

<P><B>Rationale (October, 2005):</B></P>

<P>The CWG felt that this error was not likely to arise very
often in practice.  Implementations can warn about such constructs,
and the resolution for <A HREF="
     cwg_active.html#453">issue 453</A> makes
executing such code undefined behavior; that seemed to address the
situation adequately.</P>

<P><B>Note (February, 2006):</B></P>

<P>Recent discussions  have suggested that undefined behavior be
reduced.  One possibility (broadening the scope of this issue to
include object declarations as well as references) was to require a
diagnostic if the initializer uses the value, but not just the
address, of the object or reference being declared:</P>

<PRE>
    int i = i;        //<SPAN STYLE="font-family:Times"><I> Ill-formed, diagnostic required</I></SPAN>
    void* p = &amp;p;     //<SPAN STYLE="font-family:Times"><I> Okay</I></SPAN>
</PRE>

<BR><BR><HR><A NAME="332"></A><H4>332.
  
cv-qualified <TT>void</TT> parameter types
</H4><B>Section: </B>8.3.5&#160;
 [dcl.fct]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Michiel Salters
 &#160;&#160;&#160;

 <B>Date: </B>9 Jan 2002<BR>


<P>8.3.5
 [dcl.fct]/2 restricts the use of void
as parameter type, but does not
mention CV qualified versions. Since <TT>void f(volatile void)</TT>
isn't a callable
function anyway, 8.3.5
 [dcl.fct]
should also ban cv-qualified versions.
(BTW, this follows C)</P>

<P><B>Suggested resolution:</B></P>

<P>A possible resolution would be to add (cv-qualified) before void in</P>
<BLOCKQUOTE>
The parameter list <TT>(void)</TT> is equivalent to the empty
parameter list. Except
for this special case, <B>(cv-qualified)</B> <TT>void</TT> shall
not be a parameter type (though types derived from <TT>void</TT>, such as
<TT>void*</TT>, can).
</BLOCKQUOTE>

<BR><BR><HR><A NAME="550"></A><H4>550.
  
Pointer to array of unknown bound in parameter declarations
</H4><B>Section: </B>8.3.5&#160;
 [dcl.fct]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>22 November 2005<BR>


<P>The current wording of 8.3.5
 [dcl.fct] paragraph 6
encompasses more than it should:</P>

<BLOCKQUOTE>

If the type of a parameter includes a type of the form &#8220;pointer
to array of unknown bound of <TT>T</TT>&#8221; or &#8220;reference to
array of unknown bound of <TT>T</TT>,&#8221; the program is
ill-formed. [<I>Footnote:</I> This excludes parameters of type
&#8220;<I>ptr-arr-seq</I> <TT>T2</TT>&#8221; where <TT>T2</TT> is
&#8220;pointer to array of unknown bound of <TT>T</TT>&#8221; and
where <I>ptr-arr-seq</I> means any sequence of &#8220;pointer
to&#8221; and &#8220;array of&#8221; derived declarator types. This
exclusion applies to the parameters of the function, and if a
parameter is a pointer to function or pointer to member function then
to its parameters also, etc. &#8212;<I>end footnote</I>]

</BLOCKQUOTE>

<P>The normative wording (contrary to the intention expressed in the
footnote) excludes declarations like</P>

<PRE>
    template&lt;class T&gt; struct S {};
    void f(S&lt;int (*)[]&gt;);
</PRE>

<P>and</P>

<PRE>
    struct S {};
    void f(int(*S::*)[]);
</PRE>

<P>but not</P>

<PRE>
    struct S {};
    void f(int(S::*)[]);
</PRE>

<BR><BR><HR><A NAME="577"></A><H4>577.
  
<TT>void</TT> in an empty parameter list
</H4><B>Section: </B>8.3.5&#160;
 [dcl.fct]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Ben Hutchings
 &#160;&#160;&#160;

 <B>Date: </B>22 April 2006<BR>


<P>8.3.5
 [dcl.fct] paragraph 2 says,</P>

<BLOCKQUOTE>

The parameter list <TT>(void)</TT> is equivalent to the empty
parameter list.

</BLOCKQUOTE>

<P>This special case is intended for C compatibility, but C99 describes
it differently (6.7.5.3 paragraph 10):</P>

<BLOCKQUOTE>

The special case of an unnamed parameter of type <TT>void</TT> as the
only item in the list specifies that the function has no parameters.

</BLOCKQUOTE>

<P>The C99 formulation allows typedefs for <TT>void</TT>, while C++
(and C90) accept only the keyword itself in this role.  Should the
C99 approach be adopted?</P>

<P><B>Notes from the October, 2006 meeting:</B></P>

<P>The CWG did not take a formal position on this issue; however,
there was some concern expressed over the treatment of function
templates and member functions of class templates if the C++ rule
were changed: for a template parameter <TT>T</TT>, would a function
taking a single parameter of type <TT>T</TT> become a no-parameter
function if it were instantiated with <TT>T = void</TT>?</P>

<BR><BR><HR><A NAME="713"></A><H4>713.
  
Unclear note about cv-qualified function types
</H4><B>Section: </B>8.3.5&#160;
 [dcl.fct]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Doug Gregor
 &#160;&#160;&#160;

 <B>Date: </B>11 September, 2008<BR>




<P>4.4
 [conv.qual] paragraph 3 consists of a note reading,</P>

<BLOCKQUOTE>

[<I>Note:</I> Function types (including those used in pointer to
member function types) are never cv-qualified (8.3.5
 [dcl.fct]). &#8212;<I>end note</I>]

</BLOCKQUOTE>

<P>However, 8.3.5
 [dcl.fct] paragraph 7 says,</P>

<BLOCKQUOTE>

A <I>cv-qualifier-seq</I> shall only be part of the function type...

</BLOCKQUOTE>

<P>This sounds like a contradiction, although formally it is not:
a &#8220;function type with a <I>cv-qualifier-seq</I>&#8221; is not a
&#8220;cv-qualified function type.&#8221;  It would be helpful to
make this distinction clearer.</P>

<P>Suggested resolution:</P>

<OL><LI><P>Change 8.3.5
 [dcl.fct] paragraph 7 as
follows:</P></LI>

<BLOCKQUOTE>

A <I>cv-qualifier-seq</I> shall only be part of the function type
for a non-static member function, the function type to which a
pointer to member refers, or the top-level function type of a
function typedef declaration. <B>[<I>Note:</I> A function type
that has a <I>cv-qualifier-seq</I> is not a cv-qualified type;
there are no cv-qualified function types. &#8212;<I>end
note</I>]</B> The effect of a <I>cv-qualifier-seq</I> in a
function declarator...

</BLOCKQUOTE>

<LI><P>Change 3.9.3
 [basic.type.qualifier] paragraph 3 as follows:</P></LI>

<BLOCKQUOTE>

...See 8.3.5
 [dcl.fct] and 9.3.2
 [class.this]
regarding <S>cv-qualified</S> function types <B>that have
<I>cv-qualifier</I>s</B>.

</BLOCKQUOTE>

</OL>

<BR><BR><HR><A NAME="725"></A><H4>725.
  
When should the requirement for <TT>std::Returnable&lt;T&gt;</TT>, etc., apply?
</H4><B>Section: </B>8.3.5&#160;
 [dcl.fct]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alberto Ganesh Barbati
 &#160;&#160;&#160;

 <B>Date: </B>30 September, 2008<BR>




<P>If we write</P>

<PRE>
    concept C&lt;class T&gt; {}

    template&lt;C T&gt;
    struct B {
         B f();
         virtual void g() = 0;
    };
</PRE>

<P>... it seems reasonable to expect a diagnostic about
<TT>B&lt;T&gt;::f()</TT> not because it doesn't require
<TT>std::Returnable&lt;B&lt;T&gt;&gt;</TT> (which I think should not
draw an error), but because <TT>g()</TT> is a pure virtual function.
</P>

<P>Now how about this:</P>

<PRE>
    template&lt;C T&gt;
    struct G {
         B&lt;T&gt; f() { return B&lt;T&gt;(); }
    };
</PRE>

<P>Here, I'd like to see an error not because we lack the requirement
<TT>std::Returnable&lt;B&lt;T&gt;&gt;</TT>, but because, when we
instantiate <TT>B&lt;T'&gt;</TT> (as the current wording indicates we
must within the definition of <TT>G&lt;T&gt;::f()</TT>), it turns out
to be an abstract class.</P>

<P>Now, it could be that when we instantiate <TT>G</TT>, we get a
different partial specialization of <TT>B</TT>, and that partial
specialization could have a pure virtual member.  So you might see an
instantiation-time error.  But partial specializations present dangers
like this anyway.</P>

<P>I suggest we make the rule about <TT>Returnable&lt;T&gt;</TT> apply
only in the case where <TT>T</TT> is not an instantiated archetype.
The rationale is that with an instantiated archetype, it's possible to
see at template definition time whether the type is abstract, whereas
with a non-instantiated archetype, the only known attributes come
from requirements.</P>

<P>I suspect we need similar changes for the declarator section.
E.g., for a class template <TT>A</TT>, we shouldn't need to explicitly
require <TT>VariableType&lt;A&lt;T&gt;&gt;</TT> if we want to declare a
variable of type <TT>A&lt;T&gt;</TT>.  Instead, we just instantiate
<TT>A&lt;T'&gt;</TT> (as would be naturally required at the point of
definition of a variable of type <TT>A&lt;T'&gt;</TT>), and issue
errors when appropriate like we do with ordinary classes today.
</P>

<BR><BR><HR><A NAME="325"></A><H4>325.
  
When are default arguments parsed?
</H4><B>Section: </B>8.3.6&#160;
 [dcl.fct.default]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Nathan Sidwell
 &#160;&#160;&#160;

 <B>Date: </B>27 Nov 2001<BR>


<P>The standard is not precise enough about when the default arguments of
member functions are parsed.  This leads to confusion over whether certain
constructs are legal or not, and the validity of certain compiler
implementation algorithms.</P>

<P>8.3.6
 [dcl.fct.default] paragraph 5 says "names in the
expression are bound, and
the semantic constraints are checked, at the point where the default
argument expression appears"</P>

<P>However, further on at paragraph 9 in the same section there is an example,
where the salient parts are
<PRE>
  int b;
  class X {
    int mem2 (int i = b); // OK use X::b
    static int b;
  };
</PRE>
which appears to contradict the former constraint. At the point the default
argument expression appears in the definition of X, X::b has not been
declared, so one would expect ::b to be bound.  This of course appears to
violate 3.3.6
 [basic.scope.class] paragraph 1(2) "A name N used in
a class S shall
refer to the same declaration in its context and when reevaluated in the
complete scope of S. No diagnostic is required."</P>

<P>Furthermore 3.3.6
 [basic.scope.class] paragraph 1(1) gives the
 scope of names declared
in class to "consist not only of the declarative region following
the name's declarator, but also of .. default arguments ...". Thus implying
that X::b is in scope in the default argument of X::mem2 previously.</P>

<P>That previous paragraph hints at an implementation technique of saving the
token stream of a default argument expression and parsing it at the end of
the class definition (much like the bodies of functions defined in the
class).  This is a technique employed by GCC and, from its behaviour, in
the EDG front end.  The standard leaves two things unspecified. 
Firstly, is a default argument expression permitted to call a static member
function declared later in the class in such a way as to require evaluation of
that function's default arguments? I.e. is the following well formed?
<PRE>
  class A {
    static int Foo (int i = Baz ());
    static int Baz (int i = Bar ());
    static int Bar (int i = 5);
 };
</PRE>
If that is well formed, at what point does the non-sensicalness of
<PRE>
  class B {
    static int Foo (int i = Baz ());
    static int Baz (int i = Foo());
  };
</PRE>
become detected? Is it when B is complete? Is it when B::Foo or B::Baz is
called in such a way to require default argument expansion? Or is no
diagnostic required?</P>

<P>The other problem is with collecting the tokens that form the default
argument expression.  Default arguments which contain template-ids with
more than one parameter present a difficulty in determining when the
default argument finishes.  Consider,
<PRE>
  template &lt;int A, typename B&gt; struct T { static int i;};
  class C {
    int Foo (int i = T&lt;1, int&gt;::i);
  };
</PRE>
The default argument contains a non-parenthesized comma.  Is it required
that this comma is seen as part of the default argument expression and not
the beginning of another of argument declaration?  To accept this as
part of the default argument would require name lookup of T (to determine
that the '&lt;' was part of a template argument list and not a less-than
operator) before C is complete.  Furthermore, the more pathological
<PRE>
  class D {
    int Foo (int i = T&lt;1, int&gt;::i);
    template &lt;int A, typename B&gt; struct T {static int i;};
  };
</PRE>
would be very hard to accept. Even though T is declared after Foo, T is
in scope within Foo's default argument expression.</P>

<P><B>Suggested resolution:</B></P>

<P>Append the following text to 8.3.6
 [dcl.fct.default] paragraph 8.</P>
<BLOCKQUOTE>
	The default argument expression of a member function declared in 
	the class definition consists of the sequence of tokens up until
	the next non-parenthesized, non-bracketed comma or close
	parenthesis.  Furthermore such default argument expressions shall
	not require evaluation of a default argument of a function
	declared later in the class.
</BLOCKQUOTE>

<P>This would make the above A, B, C and D ill formed and is in line with the
existing compiler practice that I am aware of.</P>

<P><B>Notes from the October, 2005 meeting:</B></P>

<P>The CWG agreed that the first example (<TT>A</TT>) is currently
well-formed and that it is not unreasonable to expect implementations
to handle it by processing default arguments recursively.</P>

<BR><BR><HR><A NAME="361"></A><H4>361.
  
Forward reference to default argument
</H4><B>Section: </B>8.3.6&#160;
 [dcl.fct.default]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Clamage
 &#160;&#160;&#160;

 <B>Date: </B>17 June 2002<BR>




<P>Is this program well-formed?</P>
<PRE>
  struct S {
    static int f2(int = f1()); // OK?
    static int f1(int = 2);
  };
  int main()
  {
    return S::f2();
  }
</PRE>
<P>A class member function can in general refer to class members that
are declared lexically later.  But what about referring to default
arguments of member functions that haven't yet been declared?</P>

<P>It seems to me that if f2 can refer to f1, it can also refer to the
default argument of f1, but at least one compiler disagrees.</P>

<BR><BR><HR><A NAME="732"></A><H4>732.
  
Late-specified return types in function definitions
</H4><B>Section: </B>8.4&#160;
 [dcl.fct.def]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daniel Kr&#252;gler
 &#160;&#160;&#160;

 <B>Date: </B>7 October, 2008<BR>




<P>The grammar in 8.4
 [dcl.fct.def] paragraph 2 incorrectly
excludes late-specified return types and should be corrected.</P>

<BR><BR><HR><A NAME="253"></A><H4>253.
  
Why must empty or fully-initialized const objects be initialized?
</H4><B>Section: </B>8.5&#160;
 [dcl.init]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>11 Jul 2000<BR>




<P>Paragraph 9 of
8.5
 [dcl.init]

 says:</P>
<BLOCKQUOTE>If no initializer is specified for an object, and the object
is of (possibly cv-qualified) non-POD class type (or array thereof), the
object shall be default-initialized; if the object is of const-qualified
type, the underlying class type shall have a user-declared default constructor.
Otherwise, if no initializer is specified for an object, the object and
its subobjects, if any, have an indeterminate initial value; if the object
or any of its subobjects are of const-qualified type, the program is ill-formed.</BLOCKQUOTE>

<P>What if a const POD object has no non-static data members?
This wording requires an empty initializer for such cases:</P>

<PRE>
    struct Z {
        // no data members
        operator int() const { return 0; }
    };

    void f() {
        const Z z1;         // ill-formed: no initializer
        const Z z2 = { };   // well-formed
    }
</PRE>

<P>Similar comments apply to a non-POD const object, all of whose
non-static data members and base class subobjects have default
constructors.  Why should the class of such an object be required
to have a user-declared default constructor?</P>

<P>(See also <A HREF="
     cwg_defects.html#78">issue 78</A>.)</P>

<BR><BR><HR><A NAME="611"></A><H4>611.
  
Zero-initializing references
</H4><B>Section: </B>8.5&#160;
 [dcl.init]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alisdair Meredith
 &#160;&#160;&#160;

 <B>Date: </B>29 December 2006<BR>


<P>According to 8.5
 [dcl.init] paragraph 5,</P>

<BLOCKQUOTE>

<P>To <I>zero-initialize</I> an object of type <TT>T</TT> means:</P>

<UL>

<LI><P>...</P></LI>

<LI><P>if <TT>T</TT> is a reference type, no initialization is
performed.</P></LI>
</UL>

</BLOCKQUOTE>

<P>However, a reference is not an object, so this makes no sense.</P>

<BR><BR><HR><A NAME="670"></A><H4>670.
  
Copy initialization via derived-to-base conversion in the second step
</H4><B>Section: </B>8.5&#160;
 [dcl.init]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jason Merrill
 &#160;&#160;&#160;

 <B>Date: </B>20 December 2007<BR>




<P>In this example:</P>

<PRE>
    struct A {};

    struct B: A {
       B(int);
       B(B&amp;);
       B(A);
    };

    void foo(B);

    void bar() {
       foo(0);
    }
</PRE>

<P>we are copy-initializing a <TT>B</TT> from <TT>0</TT>. So by
13.3.1.4
 [over.match.copy] we consider all the converting
constructors of <TT>B</TT>, and choose <TT>B(int)</TT> to create
a <TT>B</TT>.  Then, by 8.5
 [dcl.init] paragraph 15, we
direct-initialize the parameter from that temporary <TT>B</TT>.  By
13.3.1.3
 [over.match.ctor] we consider all constructors.  The copy
constructor cannot be called with a temporary, but <TT>B(A)</TT> is
callable.</P>

<P>As far as I can tell, the Standard says that this example is
well-formed, and calls <TT>B(A)</TT>.  EDG and G++ have rejected this
example with a message about the copy constructor not being callable,
but I have been unsuccessful in finding anything in the Standard that
says that we only consider the copy constructor in the second step of
copy-initialization.  I wouldn't mind such a rule, but it doesn't seem
to be there.  And implementing <A HREF="
     cwg_defects.html#391">issue 391</A>
causes G++ to start accepting the example.</P>

<P>This question came up before in
<A href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17431">a GCC bug
report</A>; in the discussion of that bug Nathan Sidwell said that
some EDG folks explained to him why the testcase is ill-formed, but
unfortunately didn't provide that explanation in the bug report.
</P>

<P>I think the resolution of <A HREF="
     cwg_defects.html#391">issue 391</A>
makes this example well-formed; it was previously ill-formed because
in order to bind the temporary <TT>B(0)</TT> to the argument of
<TT>A(const A&amp;)</TT> we needed to make another
temporary <TT>B</TT>, and that's what made the example ill-formed.  If
we want this example to stay ill-formed, we need to change something
else.</P>

<P><U>Steve Adamczyk:</U></P>

<P>I tracked down my response to Nathan at the time, and it related to
my paper N1232 (on the <TT>auto_ptr</TT> problem).  The change that
came out of that paper is in 13.3.3.1
 [over.best.ics] paragraph
4:</P>

<BLOCKQUOTE>

However, when considering the argument of a user-defined conversion
function that is a candidate by 13.3.1.3
 [over.match.ctor] when
invoked for the copying of the temporary in the second step of a class
copy-initialization, or by 13.3.1.4
 [over.match.copy], 13.3.1.5
 [over.match.conv], or 13.3.1.6
 [over.match.ref] in all cases, only
standard conversion sequences and ellipsis conversion sequences are
allowed.

</BLOCKQUOTE>

<P>This is intended to prevent use of more than one implicit user-
defined conversion in an initialization.</P>

<P>I told Nathan <TT>B(A)</TT> can't be called because its argument
would require yet another user-defined conversion, but I was wrong.  I
saw the conversion from <TT>B</TT> to <TT>A</TT> and immediately
thought &#8220;user-defined,&#8221; but in fact because <TT>B</TT> is
a derived class of <TT>A</TT> the conversion according to 13.3.3.1
 [over.best.ics] paragraph 6 is a derived-to-base Conversion (even
though it will be implemented by calling a copy constructor).</P>

<P>So I agree with you: with the analysis above and the change for
<A HREF="
     cwg_defects.html#391">issue 391</A> this example is well-formed.  We
should discuss whether we want to make a change to keep it
ill-formed.</P>

<BR><BR><HR><A NAME="737"></A><H4>737.
  
Uninitialized trailing characters in string initialization
</H4><B>Section: </B>8.5.2&#160;
 [dcl.init.string]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Kanze
 &#160;&#160;&#160;

 <B>Date: </B>26 October, 2008<BR>




<P>The current specification of string initialization in 8.5.2
 [dcl.init.string] leaves all characters of an auto character array
following the terminating <TT>'\0'</TT> uninitialized.  This is
different from C99, in which string initialization is handled like
aggregate initialization and all trailing characters are zeroed (6.7.8
paragraph 21).</P>

<P>(See also <A HREF="
     cwg_active.html#694">issue 694</A>, in which we
are considering following C99 in a somewhat similar case of
zero-initializing trailing data.)</P>

<BR><BR><HR><A NAME="656"></A><H4>656.
  
Direct binding to the result of a conversion operator
</H4><B>Section: </B>8.5.3&#160;
 [dcl.init.ref]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jason Merrill
 &#160;&#160;&#160;

 <B>Date: </B>23 October 2007<BR>




<P>Consider the following example:</P>

<PRE>
    struct A { };
    struct B : public A { };
    struct X {
       operator B();
    };
    X x;

    int main() {
       const A&amp; r = x;
       return 0;
    }
</PRE>

<P>It seems like the resolution of <A HREF="
     cwg_defects.html#391">issue 391</A> doesn't actually cover this; <TT>X</TT> is not
reference-compatible with <TT>A</TT>, so we go past the modified
bullet (8.5.3
 [dcl.init.ref] paragraph 5, bullet 2,
sub-bullet 1), which reads:</P>

<BLOCKQUOTE>

If the initializer expression is an rvalue, with <TT>T2</TT> a class
type, and &#8220;<I>cv1</I> <TT>T1</TT>&#8221; is reference-compatible
with &#8220;<I>cv2</I> <TT>T2</TT>,&#8221; the reference is bound to
the object represented by the rvalue (see 3.10
 [basic.lval])
or to a sub-object within that object.

</BLOCKQUOTE>

<P>and hit</P>

<BLOCKQUOTE>

Otherwise, a temporary of type &#8220;<I>cv1</I> <TT>T1</TT>&#8221; is
created and initialized from the initializer expression using the
rules for a non-reference copy initialization (8.5
 [dcl.init]). The reference is then bound to the temporary.

</BLOCKQUOTE>

<P>which seems to require that we create an <TT>A</TT> temporary
copied from the return value of <TT>X::operator B()</TT> rather than
bind directly to the <TT>A</TT> subobject.  I think that the
resolution of <A HREF="
     cwg_defects.html#391">issue 391</A> should cover this
situation as well, and the EDG compiler seems to agree with me.</P>

<BR><BR><HR><A NAME="511"></A><H4>511.
  
POD-structs with template assignment operators
</H4><B>Section: </B>9&#160;
 [class]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alisdair Meredith
 &#160;&#160;&#160;

 <B>Date: </B>19 Mar 2005<BR>


<P>A POD-struct is not permitted to have a user-declared copy
assignment operator (9
 [class] paragraph 4).  However, a
template assignment operator is not considered a copy assignment
operator, even though its specializations can be selected by overload
resolution for performing copy operations (12.8
 [class.copy]
paragraph 9 and especially footnote 114).  Consequently, <TT>X</TT> in
the following code is a POD, notwithstanding the fact that copy
assignment (for a non-const operand) is a member function call
rather than a bitwise copy:</P>

<PRE>
    struct X {
      template&lt;typename T&gt; const X&amp; operator=(T&amp;);
    };
    void f() {
      X x1, x2;
      x1 = x2;  //<SPAN STYLE="font-family:Times"><I> calls </I></SPAN>X::operator=&lt;X&gt;(X&amp;)
    }
</PRE>

<P>Is this intentional?</P>

<BR><BR><HR><A NAME="714"></A><H4>714.
  
Static const data members and <I>braced-init-list</I>s
</H4><B>Section: </B>9.4.2&#160;
 [class.static.data]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Adamczyk
 &#160;&#160;&#160;

 <B>Date: </B>15 September, 2008<BR>


<P>The recent changes in the handling of initialization have not
touched the requirement that the in-class initializer for a const
static data member must be of the form
<TT>=</TT>&#160;<I>assignment-expression</I> and not a
<I>braced-init-list</I>.  It would be more consistent and
general to allow the braced form as well.</P>

<BR><BR><HR><A NAME="57"></A><H4>57.
  
Empty unions
</H4><B>Section: </B>9.5&#160;
 [class.union]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Adamczyk
 &#160;&#160;&#160;

 <B>Date: </B>13 Oct 1998<BR>



<P>There doesn't seem to be a prohibition in 9.5
 [class.union]
 against a declaration
like</P>
<PRE>
    union { int : 0; } x;
</PRE>
Should that be valid?  If so, 8.5
 [dcl.init]

paragraph 5 third bullet, which deals with
default-initialization of unions, should say that no initialization is
done if there are no data members.
    
<P>What about:</P>
<PRE>
    union { } x;
    static union { };
</PRE>
If the first example is well-formed, should either or both of these cases
be well-formed as well?

<P>(See also the resolution for
<A HREF="
     cwg_defects.html#151">issue 151</A>.)</P>

<P><B>Notes from 10/00 meeting:</B> The resolution to
<A HREF="
     cwg_defects.html#178">issue 178</A>, which was accepted as a
DR, addresses the first point above (default initialization).
The other questions have not yet been decided, however.</P>
<BR><BR><HR><A NAME="716"></A><H4>716.
  
Specifications that should apply only to non-static union data members
</H4><B>Section: </B>9.5&#160;
 [class.union]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>17 September, 2008<BR>


<P>Unions are no longer forbidden to have static data members; however,
much of the wording of 9.5
 [class.union] (and possibly other
places in the Standard) is still written with that assumption and
refers only to &#8220;data members&#8221; when clearly non-static
data members are in view.  From paragraph 1, for example:</P>

<BLOCKQUOTE>

In a union, at most one of the <B>data members</B> can be active
at any time... The size of a union is sufficient
to contain the largest of its <B>data members</B>...

</BLOCKQUOTE>

<BR><BR><HR><A NAME="675"></A><H4>675.
  
Signedness of bit-field with typedef or template parameter type
</H4><B>Section: </B>9.6&#160;
 [class.bit]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Richard Corden
 &#160;&#160;&#160;

 <B>Date: </B>11 February, 2008<BR>




<P>Is the signedness of <TT>x</TT> in the following example
implementation-defined?</P>

<PRE>
    template &lt;typename T&gt; struct A {
        T x : 7;
    };

    template struct A&lt;long&gt;;
</PRE>

<P>A similar example could be created with a typedef.</P>

<P><U>Lawrence Crowl</U>: According to 9.6
 [class.bit]
paragraph 3,</P>

<BLOCKQUOTE>

It is implementation-defined whether a plain (neither explicitly
signed nor unsigned) <TT>char</TT>, <TT>short</TT>, <TT>int</TT>
or <TT>long</TT> bit-field is signed or unsigned.

</BLOCKQUOTE>

<P>This clause is conspicuously silent on typedefs and template
parameters.</P>

<P><U>Clark Nelson</U>: At least in C, the intention is that the
presence or absence of this redundant keyword is supposed to be
remembered through typedef declarations. I don't remember discussing
it in C++, but I would certainly hope that we don't want to do
something different. And presumably, we would want template type
parameters to work the same way.</P>

<P>So going back to the original example, in an instantiation of
<TT>A&lt;long&gt;</TT>, the signedness of the bit-field is
implementation-defined, but in an instantiation of <TT>A&lt;signed
long&gt;</TT>, the bit-field is definitely signed.</P>

<P><U>Peter Dimov</U>: How can this work?
Aren't <TT>A&lt;long&gt;</TT> and <TT>A&lt;signed long&gt;</TT> the
same type?</P>

(See also <A HREF="
     cwg_active.html#739">issue 739</A>.)

<BR><BR><HR><A NAME="739"></A><H4>739.
  
Signedness of plain bit-fields
</H4><B>Section: </B>9.6&#160;
 [class.bit]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>3 November, 2008<BR>


<P>9.6
 [class.bit] paragraph 3 says,</P>

<BLOCKQUOTE>

It is implementation-defined whether a plain (neither explicitly
signed nor unsigned) <TT>char</TT>, <TT>short</TT>, <TT>int</TT> or
<TT>long</TT> bit-field is signed or unsigned.

</BLOCKQUOTE>

<P>The implications of this permission for an implementation that
chooses to treat plain bit-fields as unsigned are not clear.  Does
this mean that the type of such a bit-field is adjusted to the
unsigned variant or simply that sign-extension is not performed when
the value is fetched?  C99 is explicit in specifying the former (6.7.2
paragraph 5: &#8220;for bit-fields, it is implementation-defined
whether the specifier <TT>int</TT> designates the same type as
<TT>signed int</TT> or the same type as <TT>unsigned
int</TT>&#8221;), while C90 takes the latter approach (6.5.2.1:
&#8220;Whether the high-order bit position ofa (possibly qualified)
'plain' int bit-field is treated as a sign bit is
implementation-defined&#8221;).</P>

(See also <A HREF="
     cwg_active.html#675">issue 675</A> and
<A HREF="
     cwg_active.html#741">issue 741</A>.)

<BR><BR><HR><A NAME="741"></A><H4>741.
  
&#8220;plain&#8221; <TT>long long</TT> bit-fields
</H4><B>Section: </B>9.6&#160;
 [class.bit]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>7 November, 2008<BR>


<P>The type <TT>long long</TT> is missing from the list of bit-field
types in 9.6
 [class.bit] paragraph 3 for which the
implementation can choose the signedness.  This was presumably an
oversight.  (If that is the case, we may want to reconsider the
handling of 4.5
 [conv.prom] paragraph 3: a <TT>long long</TT>
bit-field that the implementation treats as unsigned will &#8212;
pending the outcome of <A HREF="
     cwg_active.html#739">issue 739</A> &#8212;
still promote to <TT>signed long long</TT>, which can lead to
unexpected results for bit-fields with the same number of bits as
<TT>long long</TT>.)</P>

<BR><BR><HR><A NAME="380"></A><H4>380.
  
Definition of "ambiguous base class" missing
</H4><B>Section: </B>10.2&#160;
 [class.member.lookup]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jason Merrill
 &#160;&#160;&#160;

 <B>Date: </B>22 Oct 2002<BR>


<P>The term "ambiguous base class" doesn't seem to be actually defined
anywhere.  10.2
 [class.member.lookup] paragraph 7 seems like the place
to do it.</P>

<BR><BR><HR><A NAME="230"></A><H4>230.
  
Calls to pure virtual functions
</H4><B>Section: </B>10.4&#160;
 [class.abstract]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jim Hill
 &#160;&#160;&#160;

 <B>Date: </B>4 May 2000<BR>


<P>According to 10.4
 [class.abstract] paragraph 6,</P>

<BLOCKQUOTE>

Member functions can be called from a constructor (or destructor) of
an abstract class; the effect of making a virtual call (10.3
 [class.virtual]) to a pure virtual function directly or indirectly for
the object being created (or destroyed) from such a constructor (or
destructor) is undefined.

</BLOCKQUOTE>

<P>This prohibition is unnecessarily restrictive.  It should not apply
to cases in which the pure virtual function has been defined.</P>

<P>Currently the "pure" specifier for a virtual member function has
two meanings that need not be related:</P>

<OL>

<LI>A pure virtual function need not be defined.</LI>

<LI>A pure virtual function must be overridden in any concrete derived
class.</LI>

</OL>

<P>The prohibition of virtual calls to pure virtual functions arises
from the first meaning and unnecessarily penalizes those who only need
the second.</P>

<P>For example, consider a scenario such as the following.  A class
<TT>B</TT> is defined containing a (non-pure) virtual function
<TT>f</TT> that provides some initialization and is thus called from
the base class constructor.  As time passes, a number of classes are
derived from <TT>B</TT> and it is noticed that each needs to override
<TT>f</TT>, so it is decided to make <TT>B::f</TT> pure to enforce
this convention while still leaving the original definition of
<TT>B::f</TT> to perform its needed initialization.  However, the act
of making <TT>B::f</TT> pure means that every reference to <TT>f</TT>
that might occur during the execution of one of <TT>B</TT>'s
constructors must be tracked down and edited to be a qualified
reference to <TT>B::f</TT>.  This process is tedious and error-prone:
needed edits might be overlooked, and calls that actually should be
virtual when the containing function is called other than during
construction/destruction might be incorrectly changed.</P>

<P><B>Suggested resolution:</B> Allow virtual calls to pure virtual
functions if the function has been defined.</P>

<BR><BR><HR><A NAME="600"></A><H4>600.
  
Does access control apply to members or to names?
</H4><B>Section: </B>11&#160;
 [class.access]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alisdair Meredith
 &#160;&#160;&#160;

 <B>Date: </B>3 October 2006<BR>


<P>Referring to a private member of a class, 11
 [class.access]
paragraph 1 says,</P>

<BLOCKQUOTE>

its name can be used only by members and friends of the class in which
it is declared.

</BLOCKQUOTE>

<P>That wording does not appear to reflect the intent of access control,
however.  Consider the following:</P>

<PRE>
    struct S {
        void f(int);
    private:
        void f(double);
    };

    void g(S* sp) {
        sp-&gt;f(2);        //<SPAN STYLE="font-family:Times"><I> Ill-formed?</I></SPAN>
    }
</PRE>

<P>The statement from 11
 [class.access] paragraph 1 says that the
name <TT>f</TT> can be used only by members and friends of <TT>S</TT>.
Function <TT>g</TT> is neither, and it clearly contains a use of the
name <TT>f</TT>.  That appears to make it ill-formed, in spite of the fact
that overload resolution will select the public member.</P>

<P>A related question is whether the use of the term &#8220;name&#8221;
in the description of the effect of access control means that it does
not apply to constructors and destructors, which do not have names.</P>

<P><U>Mike Miller</U>: The phrase &#8220;its name can be used&#8221;
should be understood as &#8220;it can be referred to by name.&#8221;
Paragraph 4, among other places, makes it clear that access control is
applied after overload resolution.  The &#8220;name&#8221; phrasing is
there to indicate that access control does not apply where the name is
not used (in a call via a pointer, for example).</P>

<BR><BR><HR><A NAME="360"></A><H4>360.
  
Using-declaration that reduces access
</H4><B>Section: </B>11.2&#160;
 [class.access.base]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Clamage
 &#160;&#160;&#160;

 <B>Date: </B>4 June 2002<BR>




<P>I have heard a claim that the following code is valid, but I don't
see why.</P>
<PRE>
  struct A {
    int foo ();
  };

  struct B: A {
  private:
    using A::foo;
  };

  int main ()
  {
    return B ().foo ();
  }
</PRE>
<P>
It seems to me that the using declaration in B should hide the
public foo in A. Then the call to B::foo should fail because B::foo
is not accessible in main.</P>

<P>Am I missing something?</P>

<P><U>Steve Adamczyk</U>:
This is similar to the last example in 11.2
 [class.access.base].
In prose, the rule is
that if you have access to cast to a base class and you have access
to the member in the base class, you are given access in the derived
class.  In this case, A is a public base class of B and foo is public
in A, so you can access foo through a B object.  The actual permission
for this is in the fourth bullet in
11.2
 [class.access.base] paragraph 4.</P>

<P>The wording changes for <A HREF="
     cwg_defects.html#9">issue 9</A>
make this clearer, but I believe
even without them this example could be discerned to be valid.</P>

<P>See my paper J16/96-0034, WG21/N0852 on this topic.</P>

<P><U>Steve Clamage</U>:
But a using-declaration is a declaration (7.3.3
 [namespace.udecl]).
Compare with</P>
<PRE>
  struct B : A {
  private:
    int foo();
  };
</PRE>
<P>In this case, the call would certainly be invalid, even though your
argument about casting B to an A would make it OK. Your argument
basically says that an access adjustment to make something less
accessible has no effect. That also doesn't sound right.</P>

<P><U>Steve Adamczyk</U>:
I agree that is strange.  I do think that's what 11.2
 [class.access.base]
says, but perhaps that's not what we want it to say.</P>

<BR><BR><HR><A NAME="747"></A><H4>747.
  
Access of protected base classes
</H4><B>Section: </B>11.2&#160;
 [class.access.base]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Sam Saariste
 &#160;&#160;&#160;

 <B>Date: </B>18 November, 2008<BR>




<P>Consider the following example:</P>

<PRE>
    struct B { void f(){} };
    class N : protected B { };

    struct P: N { friend int main(); };
    int main() {
          N n;
          B&amp; b = n; // R
          b.f();
    }
</PRE>

<P>This code is rendered well-formed by bullet 3 of 11.2
 [class.access.base]
paragraph 4, which says that a base class <TT>B</TT> of <TT>N</TT> is
accessible at <I>R</I> if</P>

<UL><LI><P><I>R</I> occurs in a member or friend of a class <TT>P</TT>
derived from <TT>N</TT>, and an invented public member of <TT>B</TT>
would be a private or protected member of <TT>P</TT></P></LI></UL>

<P>This provision circumvents the additional restrictions on access
to protected members found in 11.5
 [class.protected] &#8212;
<TT>main()</TT> could not call <TT>B::f()</TT> directly because the
reference is not via an object of the class through which access is
obtained.  What is the purpose of this rule?</P>

<BR><BR><HR><A NAME="718"></A><H4>718.
  
Non-class, non-function friend declarations
</H4><B>Section: </B>11.4&#160;
 [class.friend]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>18 September, 2008<BR>


<P>With the change from a scope-based to an entity-based definition
of friendship (see issues <A HREF="
     cwg_defects.html#372">372</A> and
<A HREF="
     cwg_active.html#580">580</A>), it could well make sense to
grant friendship to enumerations and variables, for example:</P>

<PRE>
    enum E: int;
    class C {
      static const int i = 5;  //<SPAN STYLE="font-family:Times"><I> Private</I></SPAN>
      friend E;
      friend int x;
    };
    enum E { e = C::i; };      //<SPAN STYLE="font-family:Times"><I> OK: </I></SPAN>E<SPAN STYLE="font-family:Times"><I> is a friend</I></SPAN>
    int x = C::i;              //<SPAN STYLE="font-family:Times"><I> OK: </I></SPAN>x<SPAN STYLE="font-family:Times"><I> is a friend</I></SPAN>
</PRE>

<P>According to the current wording of 11.4
 [class.friend]
paragraph 3, the friend declaration of <TT>E</TT> is well-formed
but ignored, while the friend declaration of <TT>x</TT> is
ill-formed.</P>

<BR><BR><HR><A NAME="581"></A><H4>581.
  
Can a templated constructor be explicitly instantiated or specialized?
</H4><B>Section: </B>12.1&#160;
 [class.ctor]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mark Mitchell
 &#160;&#160;&#160;

 <B>Date: </B>19 May 2006<BR>


<P>Although it is not possible to specify a constructor's template
arguments in a constructor invocation (because the constructor has
no name but is invoked by use of the constructor's class's name), it
is possible to &#8220;name&#8221; the constructor in declarative
contexts: per 3.4.3.1
 [class.qual] paragraph 2,</P>

<BLOCKQUOTE>

In a lookup in which the constructor is an acceptable lookup result,
if the <I>nested-name-specifier</I> nominates a class <TT>C</TT>, and
the name specified after the <I>nested-name-specifier</I>, when looked
up in <TT>C</TT>, is the injected-class-name of <TT>C</TT> (clause
9
 [class]), the name is instead considered to name the
constructor of class <TT>C</TT>... Such a constructor name shall be
used only in the <I>declarator-id</I> of a declaration that names a
constructor.

</BLOCKQUOTE>

<P>Should it therefore be possible to specify <I>template-argument</I>s
for a templated constructor in an explicit instantiation or specialization?
For example,</P>

<PRE>
    template &lt;int dim&gt; struct T {};
    struct X {
      template &lt;int dim&gt; X (T&lt;dim&gt; &amp;) {};
    };

    template X::X&lt;&gt; (T&lt;2&gt; &amp;);
</PRE>

<P>If so, that should be clarified in the text.  In
particular, 12.1
 [class.ctor] paragraph 1 says,</P>

<BLOCKQUOTE>

Constructors do not have names. A special declarator syntax using an
optional sequence of <I>function-specifier</I>s (7.1.2
 [dcl.fct.spec]) followed by the constructor&#8217;s class name followed by
a parameter list is used to declare or define the constructor.

</BLOCKQUOTE>

<P>This certainly sounds as if the parameter list must immediately
follow the class name, with no allowance for a template argument
list.</P>

<P>It would be worthwhile in any event to revise this wording
to utilize the &#8220;considered to name&#8221; approach of
3.4.3.1
 [class.qual]; as it stands, this wording
sounds as if the following would be acceptable:</P>

<PRE>
    struct S {
        S();
    };
    S() { }    // <SPAN STYLE="font-family:Times"><I>qualified-id</I></SPAN> not required?
</PRE>

<P><B>Notes from the October, 2006 meeting:</B></P>

<P>It was observed that explicitly specifying the template arguments
in a constructor declaration is never actually necessary because the
arguments are, by definition, all deducible and can thus be omitted.</P>

<BR><BR><HR><A NAME="738"></A><H4>738.
  
<TT>constexpr</TT> not permitted by the syntax of constructor declarations
</H4><B>Section: </B>12.1&#160;
 [class.ctor]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Widman
 &#160;&#160;&#160;

 <B>Date: </B>27 October, 2008<BR>




<P>According to 12.1
 [class.ctor] paragraph 1, only
<I>function-specifier</I>s are permitted in the declaration of a
constructor, and <TT>constexpr</TT> is not a <I>function-specifier</I>.
(See also <A HREF="
     cwg_defects.html#263">issue 263</A>, in which the resolution
of a similar concern regarding the <TT>friend</TT> specifier did not
change 12.1
 [class.ctor] paragraph 1 but perhaps should have
done so.)</P>



<BR><BR><HR><A NAME="395"></A><H4>395.
  
Conversion operator template syntax
</H4><B>Section: </B>12.3.2&#160;
 [class.conv.fct]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>18 Dec 2002<BR>




<P>A posting in comp.lang.c++.moderated prompted me to
try the following code:</P>
<PRE>
  struct S {
    template&lt;typename T, int N&gt; (&amp;operator T())[N];
  };
</PRE>
<P>The goal is to have a (deducible) conversion operator
template to a reference-to-array type.</P>

<P>This is accepted by several front ends (g++, EDG), but
I now believe that 12.3.2
 [class.conv.fct] paragraph 1
actually prohibits this.
The issue here is that we do in fact specify (part of)
a return type.</P>

<P>OTOH, I think it is legitimate to expect that this is
expressible in the language (preferably not using the
syntax above ;-).  Maybe we should extend the syntax
to allow the following alternative?</P>
<PRE>
  struct S {
    template&lt;typename T, int N&gt; operator (T(&amp;)[N])();
  };
</PRE>

<P><U>Eric Niebler</U>:
If the syntax is extended to support this, similar constructs should also be
considered.  For instance, I can't for the life of me figure out how to
write a conversion member function template to return a member function
pointer.  It could be useful if you were defining a null_t type.  This is
probably due to my own ignorance, but getting the syntax right is tricky.</P>

<P>Eg.</P>
<PRE>
  struct null_t {
    // null object pointer. works.
    template&lt;typename T&gt; operator T*() const { return 0; }
    // null member pointer. works.
    template&lt;typename T,typename U&gt; operator T U::*() const { return 0; }
    // null member fn ptr.  doesn't work (with Comeau online).  my error?
    template&lt;typename T,typename U&gt; operator T (U::*)()() const { return 0; }
  };
</PRE>

<P><U>Martin Sebor</U>:
Intriguing question. I have no idea how to do it in a single
declaration but splitting it up into two steps seems to work:</P>
<PRE>
  struct null_t {
    template &lt;class T, class U&gt;
    struct ptr_mem_fun_t {
      typedef T (U::*type)();
    };

    template &lt;class T, class U&gt;
    operator typename ptr_mem_fun_t&lt;T, U&gt;::type () const {
      return 0;
    }
  };
</PRE>

<P><I>Note:</I> In the April 2003 meeting, the core working group
noticed that the above doesn't actually work.</P>

<BR><BR><HR><A NAME="344"></A><H4>344.
  
Naming destructors
</H4><B>Section: </B>12.4&#160;
 [class.dtor]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jamie Schmeiser
 &#160;&#160;&#160;

 <B>Date: </B>25 April 2002<BR>


<P>Note that destructors suffer from similar problems as those of
constructors dealt with in <A HREF="
     cwg_defects.html#194">issue 194</A>
and in <A HREF="
     cwg_defects.html#263">263</A> (constructors as
friends).  Also, the wording in 12.4
 [class.dtor],
paragraph 1 does not permit a
destructor to be defined outside of the memberlist.</P>

<P>Change 12.4
 [class.dtor], paragraph 1 from</P>
<BLOCKQUOTE>
...A special declarator syntax using an optional <I>function-specifier</I>
(7.1.2
 [dcl.fct.spec]) followed by <TT>~</TT> followed by
the destructor's class name followed
by an empty parameter list is used to declare the destructor in a
class definition.  In such a declaration, the <TT>~</TT> followed by the
destructor's class name can be enclosed in optional parentheses; such
parentheses are ignored....
</BLOCKQUOTE>
<P>to</P>
<BLOCKQUOTE>
...A special declarator syntax using an optional sequence of
<I>function-specifier</I>s (7.1.2
 [dcl.fct.spec]),
an optional friend keyword, an optional
sequence of <I>function-specifier</I>s (7.1.2
 [dcl.fct.spec])
followed by an optional <TT>::</TT>
scope-resolution-operator followed by an optional
<I>nested-name-specifier</I> followed by <TT>~</TT>
followed by the destructor's class
name followed by an empty parameter list is used to declare the
destructor.  The optional <I>nested-name-specifier</I> shall not be specified
in the declaration of a destructor within the member-list of the class
of which the destructor is a member.  In such a declaration, the
optional <TT>::</TT> scope-resolution-operator followed by an optional
<I>nested-name-specifier</I> followed by <TT>~</TT>
 followed by the destructor's class
name can be enclosed in optional parentheses; such parentheses are
ignored....
</BLOCKQUOTE>

<BR><BR><HR><A NAME="255"></A><H4>255.
  
Placement deallocation functions and lookup ambiguity
</H4><B>Section: </B>12.5&#160;
 [class.free]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>26 Oct 2000<BR>


<P>Paragraph 4 of 12.5
 [class.free] speaks of looking up a
deallocation function.  While it is an error if a placement
deallocation function alone is found by this lookup, there seems to be
an assumption that a placement deallocation function and a usual
deallocation function can both be declared in a given class scope
without creating an ambiguity.  The normal mechanism by which
ambiguity is avoided when functions of the same name are declared in
the same scope is overload resolution; however, there is no mention of
overload resolution in the description of the lookup.  In fact, there
appears to be nothing in the current wording that handles this case.
That is, the following example appears to be ill-formed, according to
the current wording:</P>

<PRE>
    struct S {
        void operator delete(void*);
        void operator delete(void*, int);
    };
    void f(S* p) {
        delete p;    // ill-formed: ambiguous operator delete
    }
</PRE>

<P><B>Suggested resolution</B> (Mike Miller, March 2002):</P>

<P>I think you might get the right effect by replacing
the last sentence of 12.5
 [class.free] paragraph 4
with something like:</P>
<BLOCKQUOTE>
After removing all placement deallocation functions,
the result of the lookup shall contain an unambiguous
and accessible deallocation function.
</BLOCKQUOTE>

<BR><BR><HR><A NAME="607"></A><H4>607.
  
Lookup of <I>mem-initializer-id</I>s
</H4><B>Section: </B>12.6.2&#160;
 [class.base.init]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Richard Corden
 &#160;&#160;&#160;

 <B>Date: </B>5 December 2006<BR>




<P>In an example like,</P>

<PRE>
    struct Y {};

    template &lt;typename T&gt;
    struct X : public virtual Y { };

    template &lt;typename T&gt;
    class A : public X&lt;T&gt; {
      template &lt;typename S&gt;
      A (S)
        : S ()
      {
      }
    };

    template A&lt;int&gt;::A (Y);
</PRE>

<P>Should <TT>S</TT> be found?  (<TT>S</TT> is a dependent name, so
if it resolves to a base class type in the instantiated template, it
should satisfy the requirements.)  All the compilers I tried allowed
this example, but 12.6.2
 [class.base.init] paragraph 2 says,</P>

<BLOCKQUOTE>

Names in a <I>mem-initializer-id</I> are looked up in the scope
of the constructor&#8217;s class and, if not found in that scope, are
looked up in the scope containing the constructor&#8217;s definition.

</BLOCKQUOTE>

<P>The name <TT>S</TT> is not declared in those scopes.</P>

<P><U>Mike Miller</U>: Here's another example that is accepted by
most/all compilers but not by the current wording:</P>

<PRE>
    namespace N {
      struct B { B(int); };
      typedef B typedef_B;
      struct D: B {
        D();
      };
    }

    N::D::D(): typedef_B(0) { }
</PRE>

<P>Except for the fact that the constructor function parameter
names are ignored (see paragraph 7), what the compilers seem to
be doing is essentially ordinary unqualified name lookup.</P>

<BR><BR><HR><A NAME="710"></A><H4>710.
  
Data races during construction
</H4><B>Section: </B>12.7&#160;
 [class.cdtor]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jeffrey Yasskin
 &#160;&#160;&#160;

 <B>Date: </B>3 May, 2008<BR>


<P>Consider the following example:</P>

<PRE>
    struct A {
      A() {
        std::thread(&amp;A::Func, this).detach();
      }
      virtual void Func() {
        printf("In A");
      }
    };

    struct B : public A {
      virtual void Func() {
        printf("In B");
      }
    };

    struct C : public B {
      virtual void Func() {
        printf("In C");
      }
    };

    C c;
</PRE>

<P>What is the program allowed to print?  Should it be undefined
behavior or merely unspecified which of the <TT>Func()</TT>s is
called?</P>

<P>There is a related question about which variables <TT>C::Func()</TT>
can depend on having been constructed.  Unless we want to require
the equivalent of at least <TT>memory_order_consume</TT> on the
presumed virtual function table pointer, I think the answer is just
the members of <TT>A</TT>.</P>

<P>If I instead just have</P>

<PRE>
    A a;
</PRE>

<P>I think the only reasonable behavior is to print <TT>In A</TT>.</P>

<P>Finally, given</P>

<PRE>
    struct F {
      F() {
        std::thread(&amp;F::Func, this).detach();
      }
      virtual void Func() {
        print("In F");
      }
    };

    struct G : public F {
    };

    G g;
</PRE>

<P>I can see the behavior being undefined, but I think a lot of
people would be confused if it did anything other than print
<TT>In F</TT>.</P>

<P>Suggested resolution:</P>

<P>I think the intent here is that an object should not be used in
another thread until any non-trivial constructor has been called.
One possible way of saying that would be to add a new paragraph
at the end of 12.7
 [class.cdtor]:</P>

<BLOCKQUOTE>

A constructor for a class with virtual functions or virtual
base classes modifies a memory location in the object that is
accessed by any access to a virtual function or virtual base
class or by a <TT>dynamic_cast</TT>.  [<I>Note:</I> This implies
that access to an object by another thread while it is being
constructed often introduces a data race (see
1.10
 [intro.multithread]). &#8212;<I>end note</I>]

</BLOCKQUOTE>

<BR><BR><HR><A NAME="6"></A><H4>6.
  
Should the optimization that allows a class object to alias another object also allow the case of a parameter in an inline function to alias its argument?
</H4><B>Section: </B>12.8&#160;
 [class.copy]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>unknown
 &#160;&#160;&#160;

 <B>Date: </B>unknown<BR>



<P>[Picked up by evolution group at October 2002 meeting.]</P>


 
(See also paper J16/99-0005 = WG21 N1182.)

<P>At the London meeting,
12.8
 [class.copy]
 paragraph 15 was changed to
limit the optimization described to only the following cases:</P>
<UL>
<LI>
the source is a temporary object</LI>
    
<LI>
the return value optimization</LI>
</UL>
One other case was deemed desirable as well:
<UL>
<LI>
aliasing a parameter in an inline function call to the function call argument.</LI>
</UL>
However, there are cases when this aliasing was deemed undesirable and,
at the London meeting, the committee was not able to clearly delimit which
cases should be allowed and which ones should be prohibited.
    
<P>Can we find an appropriate description for the desired cases?</P>
    
<P><B>Rationale (04/99):</B> The absence of this optimization does
not constitute a defect in the Standard,
although the proposed resolution in the paper
should be considered when the Standard is revised.</P>

<P><B>Note (March, 2008):</B></P>

<P>The Evolution Working Group has accepted the intent of this issue and
referred it to CWG for action (not for C++0x).  See paper J16/07-0033 =
WG21 N2173.</P>

<P><B>Notes from the June, 2008 meeting:</B></P>

<P>The CWG decided to take no action on this issue until an interested
party produces a paper with analysis and a proposal.</P>
<BR><BR><HR><A NAME="733"></A><H4>733.
  
Reference qualification of copy assignment operators
</H4><B>Section: </B>12.8&#160;
 [class.copy]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alberto Ganesh Barbati
 &#160;&#160;&#160;

 <B>Date: </B>9 October, 2008<BR>




<P>For increased regularity between built-in types and class types,
the copy assignment operator can be qualified with <TT>&amp;</TT>,
preventing assignment to an rvalue.  The LWG is making that change in
the Standard Library.  It would seem a good idea to make a similar
change, where possible, in the specification of implicitly-declared
assignment operators. This would be the case when all subobjects of
class type have a non-deleted copy assignment operator that is
<TT>&amp;</TT>-qualified.</P>

<BR><BR><HR><A NAME="545"></A><H4>545.
  
User-defined conversions and built-in operator overload resolution
</H4><B>Section: </B>13.3.1.2&#160;
 [over.match.oper]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Clamage
 &#160;&#160;&#160;

 <B>Date: </B>31 October 2005<BR>




<P>Consider the following example:</P>

<PRE>
    class B1 {};
    typedef void (B1::*PB1) (); //<SPAN STYLE="font-family:Times"><I> memptr to </I></SPAN>B1

    class B2 {};
    typedef void (B2::*PB2) (); //<SPAN STYLE="font-family:Times"><I> memptr to </I></SPAN>B2

    class D1 : public B1, public B2 {};
    typedef void (D1::*PD) (); //<SPAN STYLE="font-family:Times"><I> memptr to </I></SPAN>D1

    struct S {
         operator PB1(); //<SPAN STYLE="font-family:Times"><I> can be converted to </I></SPAN>PD
    } s;
    struct T {
         operator PB2(); //<SPAN STYLE="font-family:Times"><I> can be converted to </I></SPAN>PD
    } t;

    void foo() {
         s == t; //<SPAN STYLE="font-family:Times"><I> Is this an error?</I></SPAN>
    }
</PRE>

<P>According to 13.6
 [over.built] paragraph 16, there is an
<TT>operator==</TT> for <TT>PD</TT> (&#8220;For every pointer to
member type...&#8221;), so why wouldn't it be used for this
comparison?</P>

<P><U>Mike Miller</U>: The problem, as I understand it, is that
13.3.1.2
 [over.match.oper] paragraph 3, bullet 3, sub-bullet 3
is broader than it was intended to be.  It says that candidate
built-in operators must &#8220;accept operand types to which the given
operand or operands can be converted according to 13.3.3.1
 [over.best.ics].&#8221; 13.3.3.1.2
 [over.ics.user]
describes user-defined conversions as having a second standard
conversion sequence, and there is nothing to restrict that second
standard conversion sequence.</P>

<P>My initial thought on addressing this would be to say that
user-defined conversion sequences whose second standard conversion
sequence contains a pointer conversion or a pointer-to-member
conversion are not considered when selecting built-in candidate
operator functions.  They would still be applicable after the hand-off
to Clause 5 (e.g., in bringing the operands to their common type,
5.10
 [expr.eq], or composite pointer type, 5.9
 [expr.rel]), just not in constructing the list of built-in
candidate operator functions.</P>

<P>I started to suggest restricting the second standard conversion
sequence to conversions having Promotion or Exact Match rank, but that
would exclude the Boolean conversions, which are needed
for <TT>!</TT>, <TT>&amp;&amp;</TT>, and <TT>||</TT>.  (It would have
also restricted the floating-integral conversions, though, which might
be a good idea.  They can't be used implicitly, I think, because there
would be an ambiguity among all the promoted integral types; however,
none of the compilers I tested even tried those conversions because
the errors I got were not ambiguities but things like &#8220;floating
point operands not allowed for <TT>%</TT>&#8221;.)</P>

<P><U>Bill Gibbons</U>: I recall seeing this problem before, though
possibly not in committee discussions.  As written this rule makes the
set of candidate functions dependent on what classes have been
defined, including classes not otherwise required to have been defined
in order for "==" to be meaningful.  For templates this implies that
the set is dependent on what templates have been instantiated,
e.g.</P>

<PRE>
  template&lt;class T&gt; class U : public T { };
  U&lt;B1&gt; u;  //<SPAN STYLE="font-family:Times"><I> changes the set of candidate functions to include</I></SPAN>
            //<SPAN STYLE="font-family:Times"><I> </I></SPAN>operator==(U&lt;B1&gt;,U&lt;B1&gt;)<SPAN STYLE="font-family:Times"><I>?</I></SPAN>
</PRE>

<P>There may be other places where the existence of a class
definition, or worse, a template instantiation, changes the semantics
of an otherwise valid program (e.g. pointer conversions?) but it seems
like something to be avoided.</P>

<BR><BR><HR><A NAME="418"></A><H4>418.
  
Imperfect wording on error on multiple default arguments on a called function
</H4><B>Section: </B>13.3.3&#160;
 [over.match.best]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Chris Bowler
 &#160;&#160;&#160;

 <B>Date: </B>27 May 2003<BR>




<P>According to
13.3.3
 [over.match.best] paragraph 4, the following program
appears to be ill-formed:</P>
<PRE>
  void f(int, int=0);
  void f(int=0, int);

  void g() {
    f();
  }
</PRE>
<P>Though I do not expect this is the intent of this paragraph in the
standard.</P>

<P>13.3.3
 [over.match.best] paragraph 4:</P>
<BLOCKQUOTE>
If the best viable function resolves to a function for which multiple
declarations were found, and if at least
two of these declarations or the declarations they refer to in the case of
using-declarations specify a
default argument that made the function viable, the program is ill-formed.
[Example:
<PRE>
namespace A {
  extern "C" void f(int = 5);
}
namespace B {
  extern "C" void f(int = 5);
}
using A::f;
using B::f;
void use() {
f(3); //OK, default argument was not used for viability
f(); //Error: found default argument twice
}
</PRE>
end example]</BLOCKQUOTE>

<BR><BR><HR><A NAME="455"></A><H4>455.
  
Partial ordering and non-deduced arguments
</H4><B>Section: </B>13.3.3&#160;
 [over.match.best]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Rani Sharoni
 &#160;&#160;&#160;

 <B>Date: </B>19 Jan 2004<BR>


<P>
It's not clear how overloading and partial ordering handle non-deduced pairs
of corresponding arguments. For example:</P>
<PRE>
template&lt;typename T&gt;
struct A { typedef char* type; };

template&lt;typename T&gt; char* f1(T, typename A&lt;T&gt;::type);  // #1
template&lt;typename T&gt; long* f1(T*, typename A&lt;T&gt;::type*); // #2

long* p1 = f1(p1, 0); // #3
</PRE>
<P>I thought that #3 is ambiguous but different compilers disagree on that.
Comeau C/C++ 4.3.3 (EDG 3.0.3) accepted the code, GCC 3.2 and BCC 5.5
selected #1 while VC7.1+ yields ambiguity.</P>

<P>I intuitively thought that the second pair should prevent overloading from
triggering partial ordering since both arguments are non-deduced and has
different types - (char*, char**). Just like in the following:</P>
<PRE>
template&lt;typename T&gt; char* f2(T, char*);   // #3
template&lt;typename T&gt; long* f2(T*, char**); // #4

long* p2 = f2(p2, 0); // #5
</PRE>
<P>In this case all the compilers I checked found #5 to be ambiguous.
The standard and DR <A HREF="
     cwg_defects.html#214">214</A> is not clear
about how partial ordering handle such
cases.</P>

<P>I think that overloading should not trigger partial ordering (in step
13.3.3
 [over.match.best]/1/5) if some candidates have
non-deduced pairs with different
(specialized) types. In this stage the arguments are already adjusted so no
need to mention it (i.e. array to pointer). In case that one of the
arguments is non-deuced then partial ordering should only consider the type
from the specialization:</P>
<PRE>
template&lt;typename T&gt; struct B { typedef T type; };

template&lt;typename T&gt; char* f3(T, T);                   // #7
template&lt;typename T&gt; long* f3(T, typename B&lt;T&gt;::type); // #8

char* p3 = f3(p3, p3); // #9
</PRE>
<P>According to my reasoning #9 should yield ambiguity since second pair is (T,
long*). The second type (i.e. long*) was taken from the specialization
candidate of #8.
EDG and GCC accepted the code. VC and BCC found an ambiguity.</P>

<P><U>John Spicer:</U>
There may (or may not) be an issue concerning whether nondeduced
contexts are handled properly in the partial ordering rules.  In
general, I think nondeduced contexts work, but we should walk through
some examples to make sure we think they work properly.</P>

<P>Rani's description of the problem suggests that he believes that
partial ordering is done on the specialized types.  This is not
correct.  Partial ordering is done on the templates themselves,
independent of type information from the specialization.</P>

<P><B>Notes from October 2004 meeting:</B></P>

<P>John Spicer will investigate further to see if any action is
required.</P>

<BR><BR><HR><A NAME="507"></A><H4>507.
  
Ambiguity assigning class object to built-in type
</H4><B>Section: </B>13.6&#160;
 [over.built]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Adamczyk
 &#160;&#160;&#160;

 <B>Date: </B>9 Mar 2005<BR>


<P>The following example is ambiguous according to the Standard:</P>

<PRE>
    struct Y {
      operator int();
      operator double();
    };
    void f(Y y) {
      double d;
      d = y;    //<SPAN STYLE="font-family:Times"><I> Ambiguous: </I></SPAN>Y::operator int()<SPAN STYLE="font-family:Times"><I> or </I></SPAN>Y::operator double()<SPAN STYLE="font-family:Times"><I>?</I></SPAN>
    }
</PRE>

<P>The reason for the ambiguity is that 13.6
 [over.built]
paragraph 18 says that there are candidate functions
<TT>double&amp;&#160;operator=(double&amp;,&#160;int)</TT> and
<TT>double&amp;&#160;operator=(double&amp;,&#160;double)</TT> (among
others).  In each case, the second argument is converted by a
user-defined conversion sequence (13.3.3.1.2
 [over.ics.user])
where the initial and final standard conversion sequences are the
identity conversion &#8212; i.e., the conversion sequences for the
second argument are indistinguishable for each of these candidate
functions, and they are thus ambiguous.</P>

<P>Intuitively one might expect that, because it converts directly
to the target type in the assignment, <TT>Y::operator&#160;double()</TT>
would be selected, and in fact, most compilers do select it, but there
is currently no rule to distinghish between these user-defined
conversions.  Should there be?</P>

<P><B>Additional note (May, 2008):</B></P>

<P>Here is another example that is somewhat similar:</P>

<PRE>
    enum En { ec };

    struct S {
       operator int();
       operator En();
    };

    void foo () {
       S() == 0;   // ambiguous?
    }
</PRE>

<P>According to 13.6
 [over.built] paragraph 12, the candidate
functions are</P>

<UL><TT>bool operator==(<I>L</I>, <I>R</I>);</TT></UL>

<P>where <TT><I>R</I></TT> is <TT>int</TT> and <TT><I>L</I></TT>
is every promoted arithmetic type. Overload resolution proceeds in
two steps: first, for each candidate function, determine which
implicit conversion sequence is used to convert from the argument
type to the parameter type; then compare the candidate functions on
the basis of the relative costs of those conversion sequences.</P>

<P>In the case of <TT>operator==(int, int)</TT> there is a clear
winner: <TT>S::operator int()</TT> is chosen because the identity
conversion <TT>int -&gt; int</TT> is better than the promotion <TT>En
-&gt; int</TT>. For all the other candidates, the conversion for the
first parameter is ambiguous: both <TT>S::operator int()</TT> and
<TT>S::operator En()</TT> require either an integral conversion (for
integral <TT><I>L</I></TT>) or a floating-integral conversion (for
floating point <TT><I>L</I></TT>) and are thus indistinguishable.</P>

<P>These additional candidates are not removed from the set of viable
functions, however; because of 13.3.3.1
 [over.best.ics]
paragraph 10, they are assigned the &#8220;ambiguous conversion
sequence,&#8221; which &#8220;is treated as a user-defined sequence
that is indistinguishable from any other user-defined conversion
sequence.&#8221; As a result, all the viable functions are
indistinguishable and the call is ambiguous. Like the earlier example,
one might naively think that the exact match with <TT>S::operator int()</TT>
and <TT>bool operator==(int, int)</TT> would be selected, but that is not
the case.</P>

<BR><BR><HR><A NAME="749"></A><H4>749.
  
References to function types with a <I>cv-qualifier</I> or <I>ref-qualifier</I>
</H4><B>Section: </B>13.6&#160;
 [over.built]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alberto Ganesh Barbati
 &#160;&#160;&#160;

 <B>Date: </B>9 December, 2008<BR>




<P>13.6
 [over.built] paragraph 7 posits the existence of
built-in candidate <TT>operator*</TT> functions &#8220;for every
function type <I>T</I>.&#8221; However, only non-static member
function types can contain a <I>cv-qualifier</I> or
<I>ref-qualifier</I> (8.3.5
 [dcl.fct] paragraph 7), and a
reference to such a type cannot be initialized (5.2.5
 [expr.ref] paragraph 4, bullet 3, sub-bullet 2).  (See also
14.9.4
 [concept.support] paragraph 10, which disallows references
to function types with <I>cv-qualifier</I>s but is silent on
<I>ref-qualifier</I>s.)</P>

<BR><BR><HR><A NAME="110"></A><H4>110.
  
Can template functions and classes be declared in the same scope?
</H4><B>Section: </B>14&#160;
 [temp]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>28 Apr 1999<BR>




<P>According to 14
 [temp]
 paragraph 5,</P>
<BLOCKQUOTE>

Except that a function template can be overloaded either by
(non-template) functions with the same name or by other function
templates with the same name
(14.8.3
 [temp.over]
), a template name declared
in namespace scope or in class scope shall be unique in that scope.

</BLOCKQUOTE>
3.3.10
 [basic.scope.hiding]
 paragraph 2 agrees
that only functions, not function templates, can hide a class name
declared in the same scope:
<BLOCKQUOTE>

A class name (9.1
 [class.name]
) or
enumeration name (7.2
 [dcl.enum]
) can be
hidden by the name of an object, function, or enumerator declared in
the same scope.

</BLOCKQUOTE>
However, 3.3
 [basic.scope]
 paragraph 4
treats functions and template functions together in this regard:
<BLOCKQUOTE>

Given a set of declarations in a single declarative region, each of
which specifies the same unqualified name,

<UL>
<LI>they shall all refer to the same entity, or all refer to functions
and function templates; or</LI>

<LI>exactly one declaration shall declare a class name or enumeration
name that is not a typedef name and the other declarations shall all
refer to the same object or enumerator, or all refer to functions and
function templates; in this case the class name or enumeration name is
hidden</LI>

</UL>
</BLOCKQUOTE>

<P><B>John Spicer:</B> You should be able to take an existing program
and replace an existing function with a function template without
breaking unrelated parts of the program.

In addition, all of the compilers I tried allow this usage (EDG, Sun,
egcs, Watcom, Microsoft, Borland).

I would recommend that function templates be handled exactly like functions
for purposes of name hiding.</P>

<P><B>Martin O'Riordan:</B> I don't see any justification for extending
the purview of what is decidedly a hack, just for the sake of consistency.
In fact, I think we should go further and in the interest of consistency, we
should deprecate the hack, scheduling its eventual removal from the C++
language standard.</P>

<P>The hack is there to allow old C programs and especially the
'stat.h' file to compile with minimum effort (also several other Posix and X
headers).  People changing such older programs have ample opportunity to "do
it right".  Indeed, if you are adding templates to an existing program, you
should probably be placing your templates in a 'namespace', so the issue
disappears anyway.  The lookup rules should be able to provide the behaviour
you need without further hacking.</P>
<BR><BR><HR><A NAME="728"></A><H4>728.
  
Restrictions on local classes
</H4><B>Section: </B>14&#160;
 [temp]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Faisal Vali
 &#160;&#160;&#160;

 <B>Date: </B>5 October, 2008<BR>


<P>Now that the restriction against local classes being used as
template arguments has been lifted, they are more useful, yet they are
still crippled.  For some reason or oversight, the restriction against
local classes being templates or having member templates was not
lifted.  Allowing local classes to have member templates facilitates
generic programming (the reason for lifting the other restriction),
especially when it comes to the visitor-pattern (see the
<TT>boost::variant</TT> documentation and the following example) as
implemented in boost and the <TT>boost::MPL</TT> library (since
functors have to be template classes in mpl, and higher-order functors
have to have member templates to be useful).  A local class with a
member template would allow this desirable solution:</P>

<PRE>
    #include &lt;boost/variant.hpp&gt;
    int main() {
      struct times_two_generic: public boost::static_visitor&lt;&gt; {
        template &lt;typename T&gt; void operator()(T&amp; operand) const {
            operand += operand;
        }
      };

      std::vector&lt;boost::variant&lt;int, std::string&gt;&gt; vec;
      vec.push_back(21);
      vec.push_back("hello ");

      times_two_generic visitor;
      std::for_each(vec.begin(), vec.end(), boost::apply_visitor(visitor));
    }
</PRE>

<P>Is there any compelling reason not to allow this code?  Is there
any compelling reason not to allow local classes to be templates, have
friends, or be able to define their static data members at function
scope?  Wouldn't this symmetry amongst local and non-local classes
make the language more appealing and less embarrassing?</P>

<BR><BR><HR><A NAME="343"></A><H4>343.
  
Make <TT>template</TT> optional in contexts that require a type
</H4><B>Section: </B>14.2&#160;
 [temp.names]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Steve Adamczyk
 &#160;&#160;&#160;

 <B>Date: </B>23 April 2002<BR>


<P>By analogy with <TT>typename</TT>, the keyword <TT>template</TT>
used to indicate that a dependent name will be a template name should
be optional in contexts where a type is required, e.g.,
base class lists.  We could also consider member and parameter
declarations.</P>

<P>This was suggested by <A HREF="
     cwg_active.html#314">issue 314</A>.</P>

<BR><BR><HR><A NAME="579"></A><H4>579.
  
What is a &#8220;nested&#8221; <TT>&gt;</TT> or <TT>&gt;&gt;</TT>?
</H4><B>Section: </B>14.2&#160;
 [temp.names]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>11 May 2006<BR>


<P>The Standard does not normatively define which <TT>&gt;</TT> and
<TT>&gt;&gt;</TT> tokens are to be taken as closing a
<I>template-argument-list</I>; instead, 14.2
 [temp.names]
paragraph 3 uses the undefined and imprecise term
&#8220;non-nested:&#8221;</P>

<BLOCKQUOTE>

When parsing a <I>template-id</I>, the first non-nested <TT>&gt;</TT>
is taken as the end of the <I>template-argument-list</I> rather than a
greater-than operator.  Similarly, the first
non-nested <TT>&gt;&gt;</TT> is treated as two consecutive but
distinct <TT>&gt;</TT> tokens, the first of which is taken as the end
of the <I>template-argument-list</I> and completes the <I>template-id</I>.

</BLOCKQUOTE>

<P>The (non-normative) footnote clarifies that</P>

<BLOCKQUOTE>

A <TT>&gt;</TT> that encloses the <I>type-id</I> of a <TT>dynamic_cast</TT>, <TT>static_cast</TT>,
<TT>reinterpret_cast</TT> or <TT>const_cast</TT>, or which encloses the
<I>template-argument</I>s of a subsequent <I>template-id</I>, is
considered nested for the purpose of this description.

</BLOCKQUOTE>

<P>Aside from the questionable wording of this footnote (e.g., in what
sense does a single terminating character &#8220;enclose&#8221;
anything, and is a nested <I>template-id</I>
&#8220;subsequent?&#8221;) and the fact that it is non-normative, it
does not provide a complete definition of what &#8220;nesting&#8221;
is intended to mean.  For example, is the first <TT>&gt;</TT> in this
putative <I>template-id</I> &#8220;nested&#8221; or not?</P>

<PRE>
    X&lt;a ? b &gt; c : d&gt;
</PRE>

<BR><BR><HR><A NAME="440"></A><H4>440.
  
Allow implicit pointer-to-member conversion on nontype template argument
</H4><B>Section: </B>14.3&#160;
 [temp.arg]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>David Abrahams
 &#160;&#160;&#160;

 <B>Date: </B>13 Nov 2003<BR>


<P>None of my compilers accept this, which surprised me a little.  Is
the base-to-derived member function conversion considered to be a
runtime-only thing?</P>
<PRE>
  template &lt;class D&gt;
  struct B
  {
      template &lt;class X&gt; void f(X) {}
      template &lt;class X, void (D::*)(X) = &amp;B&lt;D&gt;::f&lt;X&gt; &gt;
      struct row {};
  };
  struct D : B&lt;D&gt;
  {
      void g(int);
      row&lt;int,&amp;D::g&gt; r1;
      row&lt;char*&gt; r2;
  };
</PRE>
<P><U>John Spicer</U>:
This is not among the permitted conversions listed in 14.3.</P>

<P>I'm not sure there is a terribly good reason for that.  Some of the
template argument rules for external entities were made conservatively
because of concerns about issues of mangling template argument names.</P>

<P><U>David Abrahams</U>:
I'd really like to see that restriction loosened.  It is a serious
inconvenience because there appears to be no way to supply a usable
default in this case.  Zero would be an OK default if I could use the
function pointer's equality to zero as a compile-time switch to
choose an empty function implementation:</P>
<PRE>
  template &lt;bool x&gt; struct tag {};

  template &lt;class D&gt;
  struct B
  {
      template &lt;class X&gt; void f(X) {}

      template &lt;class X, void (D::*pmf)(X) = 0 &gt;
      struct row {
          void h() { h(tag&lt;(pmf == 0)&gt;(), pmf); }
          void h(tag&lt;1&gt;, ...) {}
          void h(tag&lt;0&gt;, void (D::*q)(X)) { /*something*/}
      };
  };

  struct D : B&lt;D&gt;
  {
      void g(int);
      row&lt;int,&amp;D::g&gt; r1;
      row&lt;char*&gt; r2;
  };
</PRE>

<P>But there appears to be no way to get that effect either.  The result
is that you end up doing something like:</P>
<PRE>
      template &lt;class X, void (D::*pmf)(X) = 0 &gt;
      struct row {
          void h() { if (pmf) /*something*/ }
      };
</PRE>

<P>which invariably makes compilers warn that you're switching on a
constant expression.</P>

<BR><BR><HR><A NAME="150"></A><H4>150.
  
Template template parameters and default arguments
</H4><B>Section: </B>14.3.3&#160;
 [temp.arg.template]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>3 Aug 1999<BR>



<P>[Picked up by evolution group at October 2002 meeting.]</P>



<P>How are default template arguments handled with respect to template
template parameters?  Two separate questions have been raised:</P>

<OL>
<LI>
Do default template arguments allow a template argument to match a
template parameter with fewer template parameters, and can the
template template parameter be specialized using the smaller number of
template arguments?  For example,

<PRE>
    template &lt;class T, class U = int&gt;
    class ARG { };

    template &lt;class X, template &lt;class Y&gt; class PARM&gt;
    void f(PARM&lt;X&gt;) { }    // specialization permitted?

    void g() {
        ARG&lt;int&gt; x;        // actually ARG&lt;int, int&gt;
        f(x);              // does ARG (2 parms, 1 with default)
                           // match PARM (1 parm)?
</PRE>

Template template parameters are deducible
(14.8.2.5
 [temp.deduct.type]
 paragraph 9),
but 14.3.3
 [temp.arg.template]
 does not
specify how matching is done.

<P><U>Jack Rouse</U>:
I implemented template template parameters assuming template signature
matching is analogous to function type matching.  This seems like the
minimum reasonable implementation.  The code in the example would not
be accepted by this compiler.  However, template default arguments are
compile time entities so it seems reasonable to relax the matching
rules to allow cases like the one in the example.  But I would
consider this to be an extension to the language.</P>

<P><U>Herb Sutter</U>:
An open issue in the LWG is that the standard
doesn't explicitly permit or forbid implementations' adding additional
<I>template-parameter</I>s
to those specified by the standard, and the LWG may be
leaning toward explicitly permitting this. 
[Under this interpretation,]
if the standard is ever modified to allow additional
<I>template-parameter</I>s,
then writing "a template that takes a standard library template as a
template template parameter" won't be just ugly because you have to mention
the defaulted parameters; it would not be (portably) possible at all except
possibly by defining entire families of overloaded templates to account for
all the possible numbers of parameters
<TT>vector&lt;&gt;</TT> (or anything else) might
actually have. That seems unfortunate.</P></LI>

<LI>
Are default arguments permitted in the template parameter list of a
template template parameter?  For example,

<PRE>
    template &lt;template &lt;class T, class U = int&gt; class PARM&gt;
    class C {
        PARM&lt;int&gt; pi;
    };
</PRE>

<P><U>Jack Rouse</U>:
I decided they could not in the compiler I support.  This continues
the analogy with function type matching.  Also, I did not see a strong
need to allow default arguments in this context.</P>

<P>A class template used as a template template argument can have default
template arguments from its declarations.  How are the two sources of
default arguments to be reconciled?  The default arguments from the
template template formal could override.  But it could be cofusing if
a <I>template-id</I> using the argument template, <TT>ARG&lt;int&gt;</TT>, behaves
differently from a <I>template-id</I> using the template formal name,
<TT>FORMAL&lt;int&gt;</TT>.</P></LI>

</OL>

<P><B>Rationale (10/99):</B> Template template parameters are intended
to be handled analogously to function function parameters.  Thus the
number of parameters in a template template argument must match the
number of parameters in a template template parameter, regardless of
whether any of those paramaters have default arguments or not.  Default
arguments are allowed for the parameters of a template template
parameter, and those default arguments alone will be considered in
a specialization of the template template parameter within a template
definition; any default arguments for the parameters of a template
template argument are ignored.</P>

<P><B>Note (Mark Mitchell, February, 2006):</B></P>

<P>Perhaps it is already obvious to all, but it seems worth noting that
this extension would change the meaning of conforming programs:</P>

<PRE>
    struct Dense { static const unsigned int dim = 1; };

    template &lt;template &lt;typename&gt; class View,
              typename Block&gt;
    void operator+(float, View&lt;Block&gt; const&amp;);

    template &lt;typename Block,
              unsigned int Dim = Block::dim&gt;
    struct Lvalue_proxy { operator float() const; };

    void test_1d (void) {
        Lvalue_proxy&lt;Dense&gt; p;
        float b;
        b + p;
    }
</PRE>

<P>If <TT>Lvalue_proxy</TT> is allowed to bind to <TT>View</TT>, then the
template <TT>operator+</TT> will be used to perform addition; otherwise,
<TT>Lvalue_proxy</TT>'s implicit conversion to float, followed by the
built-in addition on floats will be used.</P>

<P><B>Note (March, 2008):</B></P>

<P>The Evolution Working Group has accepted the intent of this issue
and referred it to CWG for action (not for C++0x).  See paper
J16/07-0033 = WG21 N2173.</P>

<P><B>Notes from the June, 2008 meeting:</B></P>

<P>The CWG decided to take no action on this issue until an interested
party produces a paper with analysis and a proposal.</P>
<BR><BR><HR><A NAME="744"></A><H4>744.
  
Matching template arguments with template template parameters with parameter packs
</H4><B>Section: </B>14.3.3&#160;
 [temp.arg.template]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Faisal Vali
 &#160;&#160;&#160;

 <B>Date: </B>2 November, 2008<BR>


<P>According to <sectin_ref ref="14.3.3">14.3.3
 [temp.arg.template]</sectin_ref> paragraph 3,</P>

<BLOCKQUOTE>

A <I>template-argument</I> matches a template <I>template-parameter</I> (call it <TT>P</TT>)
when each of the template parameters in the <I>template-parameter-list</I> of
the <I>template-argument</I>'s corresponding class template or template
alias (call it <TT>A</TT>) matches the corresponding template parameter in the
<I>template-parameter-list</I> of <TT>P</TT>. When <TT>P</TT>'s
<I>template-parameter-list</I> contains a template parameter pack
(14.5.3
 [temp.variadic]), the template parameter pack will match
zero or more template parameters or template parameter packs in the
<I>template-parameter-list</I> of <TT>A</TT> with the same type and
form as the template parameter pack in <TT>P</TT> (ignoring whether
those template parameters are template parameter packs).

</BLOCKQUOTE>

<P>The immediately-preceding example, however, assumes that a parameter
pack in the parameter will match only a parameter pack in the argument:</P>

<PRE>
    template&lt;class T&gt; class A { /* ... */ };
    template&lt;class T, class U = T&gt; class B { /* ... */ };
    template&lt;class ... Types&gt; class C { /* ... */ };

    template&lt;template&lt;class ...&gt; class Q&gt; class Y { /* ... */ };

    Y&lt;A&gt; ya;  //<SPAN STYLE="font-family:Times"><I> ill-formed: a template parameter pack does not match a template parameter</I></SPAN>
    Y&lt;B&gt; yb;  //<SPAN STYLE="font-family:Times"><I> ill-formed: a template parameter pack does not match a template parameter</I></SPAN>
    Y&lt;C&gt; yc;  //<SPAN STYLE="font-family:Times"><I> OK</I></SPAN>
</PRE>

<BR><BR><HR><A NAME="638"></A><H4>638.
  
Explicit specialization and friendship
</H4><B>Section: </B>14.5.4&#160;
 [temp.friend]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>6 July 2007<BR>


<P>Is this code well-formed?</P>

<PRE>
    template &lt;typename T&gt; struct A {
        struct B;
    };

    class C {
        template &lt;typename T&gt; friend struct A&lt;T&gt;::B;
        static int bar;
    };

    template &lt;&gt; struct A&lt;char&gt; {
        struct B {
            int f() {
                return C::bar;   // Is A&lt;char&gt;::B a friend of C?
            }
        };
    };
</PRE>

<P>According to 14.5.4
 [temp.friend] paragraph 5,</P>

<BLOCKQUOTE>

A member of a class template may be declared to be a friend of a
non-template class. In this case, the corresponding member of
every specialization of the class template is a friend of the
class granting friendship.

</BLOCKQUOTE>

<P>This would tend to indicate that the example is well-formed.
However, technically <TT>A&lt;char&gt;::B</TT> does not
&#8220;correspond to&#8221; the same-named member of the class
template: 14.7.3
 [temp.expl.spec] paragraph 4 says,</P>

<BLOCKQUOTE>

The definition of an explicitly specialized class is unrelated to
the definition of a generated specialization.  That is, its
members need not have the same names, types, etc. as the members
of a generated specialization.

</BLOCKQUOTE>

<P>In other words, there are no &#8220;corresponding members&#8221;
in an explicit specialization.</P>

<P>Is this the outcome we want for examples like the preceding?
There is diversity among implementations on this question, with some
accepting the example and others rejecting it as an access violation.</P>

<BR><BR><HR><A NAME="708"></A><H4>708.
  
Partial specialization of member templates of class templates
</H4><B>Section: </B>14.5.5&#160;
 [temp.class.spec]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Widman
 &#160;&#160;&#160;

 <B>Date: </B>8 Aug, 2008<BR>




<P>The Standard does not appear to specify clearly the effect of a
partial specialization of a member template of a class template.
For example:</P>

<PRE>
    template&lt;class T&gt; struct B {
         template&lt;class U&gt; struct A { // #1
             void h() {}
         };
         template&lt;class U&gt; struct A&lt;U*&gt; {  // #2
             void f() {}
         };
    };

    template&lt;&gt; template&lt;class U&gt; struct B&lt;int&gt;::A { // #3
         void g() {}
    };

    void q(B&lt;int&gt;::A&lt;char*&gt;&amp; p) {
         p.f();  // #4
    }
</PRE>

<P>The explicit specialization at #3 replaces the primary member
template #1 of <TT>B&lt;int&gt;</TT>; however, it is not clear
whether the partial specialization #2 should be considered to
apply to the explicitly-specialized member template of
<TT>A&lt;int&gt;</TT> (thus allowing the call to <TT>p.f()</TT>
at #4) or whether the partial specialization will be used only
for specializations of <TT>B</TT> that are implicitly
instantiated (meaning that #4 could call <TT>p.g()</TT> but not
<TT>p.f()</TT>).</P>

<BR><BR><HR><A NAME="310"></A><H4>310.
  
Can function templates differing only in parameter cv-qualifiers be overloaded?
</H4><B>Section: </B>14.5.6.1&#160;
 [temp.over.link]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Andrei Iltchenko
 &#160;&#160;&#160;

 <B>Date: </B>29 Aug 2001<BR>


<P>I get the following error diagnostic [from the EDG front end]:
<PRE>
line 8: error: function template "example&lt;T&gt;::foo&lt;R,A&gt;(A)" has
          already been declared
     R  foo(const A);
        ^
</PRE>
when compiling this piece of code:
<PRE>
struct  example  {
   template&lt;class R, class A&gt;   // 1-st member template
   R  foo(A);
   template&lt;class R, class A&gt;   // 2-nd member template
   const R  foo(A&amp;);
   template&lt;class R, class A&gt;   // 3-d  member template
   R  foo(const A);
};

/*template&lt;&gt; template&lt;&gt;
int  example&lt;char&gt;::foo(int&amp;);*/


int  main()
{
   int  (example&lt;char&gt;::* pf)(int&amp;) =
      &amp;example&lt;char&gt;::foo;
}
</PRE>
</P>

<P>The implementation complains that
<PRE>
   template&lt;class R, class A&gt;   // 1-st member template
   R  foo(A);
   template&lt;class R, class A&gt;   // 3-d  member template
   R  foo(const A);
</PRE>
cannot be overloaded and I don't see any reason for it
since it is function template specializations that are
treated like ordinary non-template functions, meaning
that the transformation of a
parameter-declaration-clause into the corresponding
parameter-type-list is applied to specializations
(when determining its type) and not to function
templates.</P>

<P>What makes me think so is the contents of 14.5.6.1
 [temp.over.link]
and the following sentence from 14.8.2.1
 [temp.deduct.call] "If P is a
cv-qualified type, the top level cv-qualifiers of P
are ignored for type deduction". If the transformation
was to be applied to function templates, then there
would be no reason for having that sentence in
14.8.2.1
 [temp.deduct.call].</P>

<P>14.8.2.2
 [temp.deduct.funcaddr], which my example is
based upon, says nothing
about ignoring the top level cv-qualifiers of the
function parameters of the function template whose
address is being taken.</P>

<P>As a result, I expect that template argument deduction
will fail for the 2-nd and 3-d member templates and
the 1-st one will be used for the instantiation of the
specialization.</P>

<BR><BR><HR><A NAME="23"></A><H4>23.
  
Some questions regarding partial ordering of function templates
</H4><B>Section: </B>14.5.6.2&#160;
 [temp.func.order]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>unknown
 &#160;&#160;&#160;

 <B>Date: </B>unknown<BR>





<P><U><B>Issue 1:</B></U></P>

<P>14.5.6.2
 [temp.func.order]
 paragraph 2 says:
<BLOCKQUOTE>Given two overloaded function templates, whether one is more
specialized than another can be determined by transforming each template
in turn and using argument deduction (14.8.2
 [temp.deduct]
) to compare it to the other.</BLOCKQUOTE>
14.8.2
 [temp.deduct]
 now has 4 subsections describing argument deduction in different
situations. I think this paragraph should point to a subsection of
14.8.2
 [temp.deduct]
.</P>

<P><B>Rationale:</B></P>

<P>This is not a defect; it is not necessary to pinpoint cross-references
to this level of detail.</P>

<P><B><U>Issue 2:</U></B></P>

<P>14.5.6.2
 [temp.func.order]
 paragraph 4 says:</P>
<BLOCKQUOTE>Using the transformed function parameter list, perform argument
deduction against the other function template. The transformed template
is at least as specialized as the other if, and only if, the deduction
succeeds and the deduced parameter types are an exact match (so the deduction
does not rely on implicit conversions).</BLOCKQUOTE>
In "the deduced parameter types are an exact match", the terms exact match
do not make it clear what happens when a type T is compared to the reference
type T&amp;. Is that an exact match?



<P><B><U>Issue 3:</U></B></P>

<P>14.5.6.2
 [temp.func.order]
 paragraph 5 says:</P>
<BLOCKQUOTE>A template is more specialized than another if, and only if,
it is at least as specialized as the other template and that template is
not at least as specialized as the first.</BLOCKQUOTE>
What happens in this case:
<PRE>
    template&lt;class T&gt; void f(T,int);
    template&lt;class T&gt; void f(T, T);
    void f(1,1);
</PRE>
For the first function template, there is no type deduction for the second
parameter. So the rules in this clause seem to imply that the second function
template will be chosen.

<P><B>Rationale:</B></P>

<P>This is not a defect; the standard unambiguously makes the above example
ill-formed due to ambiguity.</P>
<BR><BR><HR><A NAME="402"></A><H4>402.
  
More on partial ordering of function templates
</H4><B>Section: </B>14.5.6.2&#160;
 [temp.func.order]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Nathan Sidwell
 &#160;&#160;&#160;

 <B>Date: </B>7 Apr 2003<BR>




<P>This was split off from <A HREF="
     cwg_defects.html#214">issue 214</A> at
the April 2003 meeting.</P>

<P><U>Nathan Sidwell</U>:
John Spicer's proposed resolution does not make the following
well-formed.</P>
<PRE>
  template &lt;typename T&gt; int Foo (T const *) {return 1;} //#1
  template &lt;unsigned I&gt; int Foo (char const (&amp;)[I]) {return 2;} //#2

  int main ()
  {
    return Foo ("a") != 2;
  }
</PRE>
<P>Both #1 and #2 can deduce the "a" argument, #1 deduces T as char and
#2 deduces I as 2. However, neither is more specialized because the
proposed rules do not have any array to pointer decay.</P>

<P>#1 is only deduceable because of the rules in
14.8.2.1
 [temp.deduct.call] paragraph 2 that
decay array and function type arguments when the template parameter is
not a reference. Given that such behaviour happens in deduction, I believe
there should be equivalent behaviour during partial ordering. #2 should be
resolved as more specialized as #1. The following alteration to the
proposed resolution of DR214 will do that.</P>

<P>Insert before,</P>
<UL>
<LI>If A is a cv-qualified type, A is replaced by the
         cv-unqualified version of A.</LI>
</UL>
<P>the following</P>
<UL>
<LI>If P was not originally a reference type,
<UL>
<LI>If A is an array type, A is replaced by the pointer type produced
            by the array to pointer conversion</LI>
<LI>If A is a function type, A is replaced by the pointer type
            produced by the function to pointer conversion</LI>
</UL>
</LI>
</UL>

<P>For the example above, this change results in deducing 'T const *' against
'char const *' in one direction (which succeeds), and 'char [I]'
against 'T const *' in the other (which fails).</P>

<P><U>John Spicer</U>:
I don't consider this a shortcoming of my proposed wording, as I don't
think this is part of the current rules.  In other words, the
resolution of 214 might make it clearer how this case is handled
(i.e., clearer that it is not allowed), but I don't believe it
represents a change in the language.</P>

<P>I'm not necessarily opposed to such a change, but I think it should be
reviewed by the core group as a related change and not a defect in the
proposed resolution to 214.</P>

<P><B>Notes from the October 2003 meeting:</B></P>

<P>There was some sentiment that it would be desirable to have
this case ordered, but we don't think it's worth spending the
time to work on it now.  If we look at some larger partial
ordering changes at some point, we will consider this again.</P>

<BR><BR><HR><A NAME="186"></A><H4>186.
  
Name hiding and template <I>template-parameter</I>s
</H4><B>Section: </B>14.6.1&#160;
 [temp.local]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>11 Nov 1999<BR>





<P>The standard prohibits a class template from having the same name as
one of its template parameters
(14.6.1
 [temp.local]
 paragraph 4).  This prohibits</P>

<PRE>
    template &lt;class X&gt; class X;
</PRE>

for the reason that the template name would hide the parameter, and
such hiding is in general prohibited.

<P>Presumably, we should also prohibit</P>

<PRE>
    template &lt;template &lt;class T&gt; class T&gt; struct A;
</PRE>

for the same reason.
<BR><BR><HR><A NAME="459"></A><H4>459.
  
Hiding of template parameters by base class members
</H4><B>Section: </B>14.6.1&#160;
 [temp.local]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>2 Feb 2004<BR>


<P>Currently, member of nondependent base classes hide
references to template parameters in the definition
of a derived class template.</P>

<P>Consider the following example:</P>
<PRE>
   class B {
      typedef void *It;    // (1)
      // ...
    };

    class M: B {};

    template&lt;typename&gt; X {};

    template&lt;typename It&gt; struct S   // (2)
        : M, X&lt;It&gt; {   // (3)
      S(It, It);   // (4)
      // ...
    };
</PRE>
<P>As the C++ language currently stands, the name "It"
in line (3) refers to the template parameter declared
in line (2), but the name "It" in line (4) refers to
the typedef in the private base class (declared in
line (1)).</P>

<P>This situation is both unintuitive and a hindrance
to sound software engineering.  (See also the Usenet
discussion at http://tinyurl.com/32q8d .)  Among
other things, it implies that the private section
of a base class may change the meaning of the derived
class, and (unlike other cases where such things
happen) there is no way for the writer of the derived
class to defend the code against such intrusion (e.g.,
by using a qualified name).</P>

<P>Changing this can break code that is valid today.
However, such code would have to:
<OL>
<LI>
name a template parameter and not use it
         after the opening brace, and
</LI>
<LI>
use that same name to access a base-class
         name within the braces.
</LI>
</OL>
I personally have no qualms breaking such a program.</P>

<P>It has been suggested to make situations like these
ill-formed.  That solution is unattractive however
because it still leaves the writer of a derived class
template without defense against accidental name
conflicts with base members.  (Although at least the
problem would be guaranteed to be caught at compile
time.)  Instead, since just about everyone's intuition
agrees, I would like to see the rules changed to
make class template parameters hide members of the
same name in a base class.</P>

<P>See also <A HREF="
     cwg_active.html#458">issue 458</A>.</P>

<P><B>Notes from the March 2004 meeting:</B></P>

<P>We have some sympathy for a change, but the current rules fall
straightforwardly out of the lookup rules, so they're not
&#8220;wrong.&#8221; Making private members invisible also would solve
this problem.  We'd be willing to look at a paper proposing that.</P>

<P><B>Additional discussion (April, 2005):</B></P>



<P><U>John Spicer</U>: Base class members are more-or-less treated as
members of the class, [so] it is only natural that the base [member]
would hide the template parameter.</P>

<P><U>Daveed Vandevoorde</U>: Are base class members really
&#8220;more or less&#8221; members of the class from a lookup
perspective?  After all, derived class members can hide base class
members of the same name.  So there is some pretty definite
boundary between those two sets of names.  IMO, the template
parameters should either sit between those two sets, or they
should (for lookup purposes) be treated as members of the class
they parameterize (I cannot think of a practical difference
between those two formulations).</P>

<P><U>John Spicer</U>: How is [hiding template parameters]
different from the fact that namespace members can be hidden
by private parts of a base class?  The addition of <TT>int C</TT>
to <TT>N::A</TT> breaks the code in namespace <TT>M</TT> in this
example:</P>

<PRE>
    namespace N {
       class A {
    private:
         int C;
       };
    }

    namespace M {
       typedef int C;
       class B : public N::A {
         void f() {
             C c;
         }
       };
    }
</PRE>

<P><U>Daveed Vandevoorde</U>: C++ has a mechanism in place to handle
such situations: qualified names.  There is no such mechanism in place
for template parameters.</P>

<P><U>Nathan Myers</U>: What I see as obviously incorrect ... is
simply that a name defined right where I can see it, and directly
attached to the textual scope of <TT>B</TT>'s class body, is ignored
in favor of something found in some other file.  I don't care that
<TT>C1</TT> is defined in <TT>A</TT>, I have a <TT>C1</TT> right
here that I have chosen to use.  If I want <TT>A::C1</TT>, I can
say so.</P>

<P>I doubt you'll find any regular C++ coder who doesn't find the
standard behavior bizarre.  If the meaning of any code is changed
by fixing this behavior, the overwhelming majority of cases will
be mysterious bugs magically fixed.</P>

<P><U>John Spicer</U>: I have not heard complaints that this is
actually a cause of problems in real user code.  Where is the
evidence that the status quo is actually causing problems?</P>

<P>In this example, the <TT>T2</TT> that is found is the one from
the base class.  I would argue that this is natural because base
class members are found as part of the lookup in class <TT>B</TT>:</P>

<PRE>
    struct A {
             typedef int T2;
    };
    template &lt;class T2&gt; struct B : public A {
             typedef int T1;
             T1 t1;
             T2 t2;
    };
</PRE>

<P>This rule that base class members hide template parameters was
formalized about a dozen years ago because it fell out of the
principle that base class members should be found at the same
stage of lookup as derived class members, and that to do otherwise
would be surprising.</P>

<P><U>Gabriel Dos Reis</U>: The bottom line is that:</P>

<OL>

<LI>the proposed change is a <B>silent</B> change of meaning;</LI>

<LI>the proposed change does not make the language any more regular;
the current behavior is consistent with everything else, however
&#8220;surprising&#8221; that might be;</LI>

<LI>the proposed change does have its own downsides.</LI>

</OL>

<P>Unless presented with real major programming problems the current
rules exhibit, I do not think the simple rule &#8220;scopes
nest&#8221; needs a change that silently mutates program meaning.</P>

<P><U>Mike Miller</U>: The rationale for the current specification is
really very simple:</P>

<OL>

<LI>&#8220;Unless redeclared in the derived class, members of a base
class are also considered to be members of the derived class.&#8221;
(10
 [class.derived] paragraph 2)</LI>

<LI>In class scope, members hide nonmembers.</LI>

</OL>

<P>That's it.  Because template parameters are not members, they
are hidden by member names (whether inherited or not).  I don't find
that &#8220;bizarre,&#8221; or even particularly surprising.</P>

<P>I believe these rules are straightforward and consistent, so I
would be opposed to changing them.  However, I am not unsympathetic
toward Daveed's concern about name hijacking from base classes.  How
about a rule that would make a program ill-formed if a direct or
inherited member hides a template parameter?</P>

<P>Unless this problem is a lot more prevalent than I've heard so
far, I would not want to change the lookup rules; making this kind of
collision a diagnosable error, however, would prevent hijacking
without changing the lookup rules.</P>

<P><U>Erwin Unruh</U>: I have a different approach that is consistent
and changes the interpretation of the questionable code.  At present
lookup is done in this sequence:</P>

<UL>
block scope<BR>
derived class scope<BR>
base class scope<BR>
template parameters<BR>
namespace scope
</UL>

<P>If we change this order to</P>

<UL>
template parameters<BR>
block scope<BR>
derived class scope<BR>
base class scope<BR>
namespace scope<BR>
</UL>

<P>it is still consistent in that no lookup is placed between the base
class and the derived class.  However, it introduces another
inconsistency: now scopes do not nest the same way as curly braces
nest &#8212; but base classes are already inconsistent this way.</P>

<P><U>Nathan Myers</U>: This looks entirely satisfactory.  If even this
seems like too big a change, it would suffice to say that finding a
different name by this search order makes the program ill-formed.
Of course, a compiler might issue only a portability warning in that
case and use the name found Erwin's way, anyhow.</P>

<P><U>Gabriel Dos Reis</U>: It is a simple fact, even without
templates, that a writer of a derived class cannot protect himself
against declaration changes in the base class.</P>

<P><U>Richard Corden</U>: If a change is to be made, then making it
ill-formed is better than just changing the lookup rules.</P>

<PRE>
    struct B
    {
      typedef int T;
      virtual void bar (T const &amp; );
    };

    template &lt;typename T&gt;
    struct D : public B
    {
      virtual void bar (T const &amp; );
    };

    template class D&lt;float&gt;;
</PRE>

<P>I think changing the semantics of the above code silently would
result in very difficult-to-find problems.</P>

<P><U>Mike Miller</U>: Another case that may need to be considered in
deciding on Erwin's suggestion or the &#8220;ill-formed&#8221;
alternative is the treatment of <TT>friend</TT> declarations
described in 3.4.1
 [basic.lookup.unqual] paragraph 10:</P>

<PRE>
    struct A {
        typedef int T;
        void f(T);
    };
    template&lt;typename T&gt; struct B {
        friend void A::f(T);  //<SPAN STYLE="font-family:Times"><I> Currently </I></SPAN>T<SPAN STYLE="font-family:Times"><I> is </I></SPAN>A::T
    };
</PRE>

<P><B>Notes from the October, 2005 meeting:</B></P>

<P>The CWG decided not to consider a change to the existing rules at
this time without a paper exploring the issue in more detail.</P>
<BR><BR><HR><A NAME="602"></A><H4>602.
  
When is the injected-class-name of a class template a template?
</H4><B>Section: </B>14.6.1&#160;
 [temp.local]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>23 October 2006<BR>




<P>Consider the following example:</P>

<PRE>
    template&lt;class T&gt;
    struct A {
         template&lt;class U&gt;
             friend struct A; // Which A?
    };
</PRE>

<P>Presumably the lookup for <TT>A</TT> in the friend declaration finds
the injected-class-name of the template.  However, according to
14.6.1
 [temp.local] paragraph 1,</P>

<BLOCKQUOTE>

The injected-class-name can be used with or without a
<I>template-argument-list</I>. When it is used without a
<I>template-argument-list</I>, it is equivalent to the
injected-class-name followed by the <I>template-parameter</I>s of the
class template enclosed in <TT>&lt;&gt;</TT>. When it is used with a
<I>template-argument-list</I>, it refers to the specified class
template specialization, which could be the current specialization or
another specialization.

</BLOCKQUOTE>

<P>If that rule applies, then this example is ill-formed (because you
can't have a <I>template-argument-list</I> in a class template
declaration that is not a partial specialization).</P>

<P><U>Mike Miller</U>: The injected-class-name has a dual nature, as
described in 14.6.1
 [temp.local], acting as either a
template name or a class name, depending on the context; a template
argument list forces the name to be interpreted as a template.  It
seems reasonable that in this example the injected-class-name has to
be understood as referring to the class template; a template header is
at least as strong a contextual indicator as a template argument list.
However, the current wording doesn't say that.</P>

<BR><BR><HR><A NAME="591"></A><H4>591.
  
When a dependent base class is the current instantiation
</H4><B>Section: </B>14.6.2&#160;
 [temp.dep]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Widman
 &#160;&#160;&#160;

 <B>Date: </B>24 August 2006<BR>




<P>Is the following example well-formed?</P>

<PRE>
    template&lt;class T&gt; struct A {
         typedef int M;
         struct B {
             typedef void M;
             struct C;
         };
    };

    template&lt;class T&gt; struct A&lt;T&gt;::B::C : A&lt;T&gt; {
         M  // A&lt;T&gt;::M or A&lt;T&gt;::B::M?
             p[2];
    };
</PRE>

<P>14.6.2
 [temp.dep] paragraph 3 says the use
of <TT>M</TT> should refer to <TT>A&lt;T&gt;::B::M</TT> because
the base class <TT>A&lt;T&gt;</TT> is not searched because it's
dependent.  But in this case <TT>A&lt;T&gt;</TT> is also the
current instantiation (14.6.2.1
 [temp.dep.type]) so it
seems like it should be searched.
</P>

<BR><BR><HR><A NAME="502"></A><H4>502.
  
Dependency of nested enumerations and enumerators
</H4><B>Section: </B>14.6.2.1&#160;
 [temp.dep.type]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mark Mitchell
 &#160;&#160;&#160;

 <B>Date: </B>05 Feb 2005<BR>


<P>The Standard is currently silent on the dependency status of
enumerations and enumerators that are members of class templates.
There are three questions that must be answered in this regard:</P>

<OL>

<LI><P><B>Are enumeration members of class templates dependent
types?</B></P>

<P>It seems clear that nested enumerations must be dependent.  For
example:</P>

<PRE>
    void f(int);

    template&lt;typename T&gt; struct S {
        enum E { e0 };
        void g() {
            f(e0);
        }
    };

    void f(S&lt;int&gt;::E);

    void x() {
        S&lt;int&gt; si;
        si-&gt;g();       // Should call f(S&lt;int&gt;::E)
    }
</PRE>

</LI>

<LI><P><B>Is <TT>sizeof</TT> applied to a nested enumeration a
value-dependent expression (14.6.2.3
 [temp.dep.constexpr])?</B></P>

<P>There are three distinct cases that might have different answers
to this question:</P>

<UL>

<LI><PRE>
    template&lt;typename T&gt; struct S {
        enum E { e0 };
    };
</PRE>

<P>Here, the size of <TT>E</TT> is, in principle, known at the time
the template is defined.</P>

</LI>

<LI><PRE>
    template&lt;short I&gt; struct S {
        enum E { e0 = I };
    };
</PRE>

<P>In this case, the minimum size required for <TT>E</TT> cannot be
determined until instantiation, but it is clear that the underlying
type need be no larger than <TT>short</TT>.</P>

</LI>

<LI><PRE>
    template&lt;typename T&gt; struct S {
        enum E { e0 = T::e0; };
    }
</PRE>

<P>Here, nothing can be known about the size of <TT>E</TT> at the time
the template is defined.</P>

</LI>

</UL>

<P>14.6.2.3
 [temp.dep.constexpr] paragraph 2 says that a
<TT>sizeof</TT> expression is value-dependent if the type of the
operand is type-dependent.  Unless enumerations are given special
treatment, all three of these examples will have value-dependent
sizes.  This could be surprising for the first case, at least, if not
the second as well.</P>

</LI>

<LI><P><B>Are nested enumerators value-dependent expressions?</B></P>

<P>Again the question of dependent initializers comes into play.  As an
example, consider:</P>

<PRE>
    template&lt;short I&gt; struct S {
        enum E { e0, e1 = I, e2 };
    };
</PRE>

<P>There seem to be three possible approaches as to whether the
enumerators of <TT>E</TT> are value-dependent:</P>

<OL type="A">

<LI><P>The enumerators of a nested enumeration are all
value-dependent, regardless of whether they have a value-dependent
initializer or not.  This is the current position of 14.6.2.3
 [temp.dep.constexpr] paragraph 2, which says that an identifier is
value-dependent if it is a name declared with a dependent
type.</P></LI>

<LI><P>The enumerators of a nested enumeration are all value-dependent
if any of the enumeration's enumerators has a value-dependent
initializer.  In this approach, <TT>e0</TT> would be value-dependent,
even though it is clear that it has the value 0.</P></LI>

<LI><P>An enumerator of a nested enumeration is value-dependent only
if it has a value-dependent initializer (explict or implicit).  This
approach would make <TT>e1</TT> and <TT>e2</TT> value-dependent, but
not <TT>e0</TT>.</P></LI>

</OL>

<P>An example that bears on the third approach is the following:</P>

<PRE>
    template&lt;typename T&gt; struct S {
        enum E { N = UINT_MAX, O = T::O };
        int a[N + 2];
    };
</PRE>

<P>With the normal treatment of enumerations, the type of <TT>a</TT>
might be either <TT>int[UINT_MAX+2]</TT> or <TT>int[1]</TT>, depending
on whether the value of <TT>T::O</TT> was such that the underlying
type of <TT>E</TT> is <TT>unsigned int</TT> or <TT>long</TT>.
</P>

<P>One possibility for addressing this problem under the third
approach would be to treat a given enumerator as having the type of
its initializer in such cases, rather than the enumeration type.  This
would be similar to the way enumerators are treated within the
enumerator list, before the enumeration declaration is complete
(<sectioin_ref ref="7.2">7.2
 [dcl.enum]</sectioin_ref> paragraph 5).  The argument against this
is that it makes arithmetic using enumerators behave differently when
the enumeration is a member of a class template and when it is not.</P>

</LI>

</OL>

<P><B>Notes from the April, 2005 meeting:</B></P>

<P>The CWG agreed on the following positions:</P>

<OL><LI><P>Nested enumerations are dependent types.</P></LI>

<LI><P>The result of the <TT>sizeof</TT> operator applied to a
nested enumeration is value-dependent unless there are no
dependent initializers in its definition; the first case above
is not dependent, while the second and third are dependent.</P>
</LI>

<LI><P>The approach described in 3.C above is correct.  This is
similar to the treatment of static const integral data members,
which are dependent only if their initializer is dependent.</P></LI>

</OL>

<P><B>Notes from the October, 2005 meeting:</B></P>

<P>There was no consensus among the CWG regarding question #3
(which enumerators should be considered value-dependent).  The
argument in favor of 3.C is principally that the values of enumerators
with non-dependent initializers are known at definition time, so there
is no need to treat them as dependent.</P>

<P>One objection to 3.C is that, according to the consensus of the
CWG, the enumeration type is dependent and thus even the known values
of the enumeration would have a dependent type, which could affect the
results when such enumerations are used in expressions.  A possible
response to this concern would be to treat non-dependent initializers
as having the type of the initializer rather than the enumeration
type, similar to the treatment of enumerators within
the <I>enumerator-list</I> (7.2
 [dcl.enum] paragraph 5).
However, this approach would be inconsistent with the treatment of
other enumeration types.  It would also interfere with overload
resolution (e.g., the call in the example under question #1 above
would resolve to <TT>f(int)</TT> with this approach rather
than <TT>f(S&lt;int&gt;::E)</TT>).</P>

<P>Those in favor of option 3.A also suggested that it would be simpler
and require less drafting: if all the enumerators have the (dependent)
type of the enumeration, 14.6.2.3
 [temp.dep.constexpr] paragraph 2
already says that a name with a dependent type is value-dependent, so
nothing further would need to be said.  Option 3.C would require
additional caveats to exempt some enumerators.</P>

<P>The proponents of 3.A also pointed out that there are many other
cases where a known value with a dependent type is treated as dependent:</P>

<PRE>
    static const T t = 0;
    ... A&lt;t&gt; ...
</PRE>

<P>or</P>

<PRE>
    template &lt;int I&gt; void f() {
        g(I-I);
    }
</PRE>

<P>With regard to current practice, g++ and MSVC++ implement 3.A, while
EDG implements 3.C.</P>

<BR><BR><HR><A NAME="590"></A><H4>590.
  
Nested classes and the &#8220;current instantiation&#8221;
</H4><B>Section: </B>14.6.2.1&#160;
 [temp.dep.type]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Widman
 &#160;&#160;&#160;

 <B>Date: </B>23 August 2006<BR>




<P>In 14.6.2.1
 [temp.dep.type] paragraph 5 we have:</P>

<BLOCKQUOTE>

A name is a <I>member of an unknown specialization</I> if the name is a
<I>qualified-id</I> in which the <I>nested-name-specifier</I>
names a dependent type that is not the current instantiation.

</BLOCKQUOTE>

<P>So given:</P>

<PRE>
    template&lt;class T&gt; struct A {
        struct B {
            struct C {
                A&lt;T&gt;::B::C f();
            };
        };
    };
</PRE>

<P>it appears that the name <TT>A&lt;T&gt;::B::C</TT> should be
taken as a member of an unknown specialization, because the WP
refers to &#8220;the&#8221; current instantiation, implying that
there can be at most one at any given time.  At the declaration
of <TT>f()</TT>, the current instantiation is <TT>C</TT>,
so <TT>A&lt;T&gt;::B</TT> is not the current instantiation.</P>

<P>Would it be better to refer to &#8220;a known instantiation&#8221;
instead of &#8220;the current instantiation?&#8221;</P>

<P><U>Mike Miller</U>:</P>

<P>I agree that there is a problem here, but I don't think the
&#8220;current instantiation&#8221; terminology needs to be
replaced.  By way of background, paragraph 1 makes it clear that
<TT>A&lt;T&gt;::B</TT> &#8220;refers to&#8221; the current
instantiation:</P>

<BLOCKQUOTE>

<P>In the definition of a class template, a nested class of a
class template, a member of a class template, or a member of a
nested class of a class template, a name refers to the <I>current
instantiation</I> if it is</P>

<UL><LI><P>the injected-class-name (9
 [class]) of
the class template or nested class,</P></LI>

<LI><P>in the definition of a primary class template, the name of
the class template followed by the template argument list of the
primary template (as described below) enclosed
in <TT>&lt;&gt;</TT>,</P></LI>

<LI><P>in the definition of a nested class of a class template,
the name of the nested class referenced as a member of the
current instantiation...</P></LI>

</UL>

</BLOCKQUOTE>

<P><TT>A&lt;T&gt;::B</TT> satisfies bullet 3.  Paragraph 4 says,</P>

<BLOCKQUOTE>

<P>A name is a member of the current instantiation if it is</P>

<UL><LI><P>An unqualified name that, when looked up, refers to a
member of a class template. [<I>Note:</I> this can only occur
when looking up a name in a scope enclosed by the definition of a
class template. &#8212;<I>end note</I>]</P></LI>

<LI><P>A <I>qualified-id</I> in which
the <I>nested-name-specifier</I> refers to the current
instantiation.</P></LI>

</UL>

</BLOCKQUOTE>

<P>So clearly by paragraphs 1 and 4, <TT>A&lt;T&gt;::B::C</TT> is
a member of the current instantiation.  The problem is in the
phrasing of paragraph 5, which incorrectly requires that the
<I>nested-name-specifier</I> &#8220;be&#8221; the current
instantiation rather than simply &#8220;referring to&#8221; the
current instantiation, which would be the correct complement to
paragraph 4.  Perhaps paragraph 5 could simply be rephrased as,
&#8220;...a dependent type and it is not a member of the current
instantiation.&#8221;</P>

<P>(Paragraph 1 may require a bit more wordsmithing to make it
truly recursive across multiple levels of nested classes; as it
stands, it's not clear whether the name of a nested class of a
nested class of a class template is covered or not.)</P>

<BR><BR><HR><A NAME="293"></A><H4>293.
  
Syntax of explicit instantiation/specialization too permissive
</H4><B>Section: </B>14.7.2&#160;
 [temp.explicit]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mark Mitchell
 &#160;&#160;&#160;

 <B>Date: </B>27 Jun 2001<BR>


<P>14.7.2
 [temp.explicit] defines an explicit instantiation as</P>

<UL><I>explicit-instantiation</I>:
<UL><TT>template</TT> <I>declaration</I></UL>
</UL>

<P>Syntactically, that allows things like:</P>
<PRE>
    template int S&lt;int&gt;::i = 5, S&lt;int&gt;::j = 7;
</PRE>

<P>which isn't what anyone actually expects.  As far as I can tell,
nothing in the standard explicitly forbids this, as written.  Syntactically,
this also allows:</P>

<PRE>
    template namespace N { void f(); }
</PRE>

<P>although perhaps the surrounding context is enough to suggest that this is
invalid.</P>

<P><B>Suggested resolution:</B></P>

<P>I think we should say:</P>

<UL><I>explicit-instantiation</I>:
<UL><I>type-specifier-seq</I><SUB>opt</SUB>
    <I>declarator</I><SUB>opt</SUB> <TT>;</TT></UL>
</UL>

<P><I>[Steve Adamczyk: presumably, this should have</I>
<TT>template</TT> <I>at the beginning.]</I></P>

<P>and then say that:</P>

<UL>
<LI>
The declarator can be omitted only when the <I>type-specifier-seq</I>
consists solely of an <I>elaborated-type-specifier</I> for a class type, in
which case the instantiation is for the named class.  If the
declarator is present the instantiation is for the named entity.
</LI>
<LI>
The <I>type-specifier-seq</I> can be omitted only when the declarator
is for a constructor, destructor, or conversion operator.
</LI>
<LI>
The <I>type-specifier-seq</I> cannot define any new types.
</LI>
</UL>

<P>There are similar problems in 14.7.3
 [temp.expl.spec]:</P>

<UL><I>explicit-specialization</I>:
<UL><TT>template</TT> &lt;&gt; <I>declaration</I></UL>
</UL>

<P>Here, I think we want:</P>

<UL><I>explicit-specialization</I>:
<UL><I>decl-specifier-seq</I><SUB>opt</SUB> <I>init-declarator</I><SUB>opt</SUB> <TT>;</TT></UL>
</UL>

<P>with similar restrictions as above.</P>

<P><I>[Steve Adamczyk: This also needs to have</I>
<TT>template &lt;&gt;</TT> <I>at the beginning, possibly repeated.]</I></P>



<BR><BR><HR><A NAME="727"></A><H4>727.
  
In-class explicit specializations
</H4><B>Section: </B>14.7.3&#160;
 [temp.expl.spec]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Faisal Vali
 &#160;&#160;&#160;

 <B>Date: </B>5 October, 2008<BR>


<P>14.7.3
 [temp.expl.spec] paragraph 2 requires that explicit
specializations of member templates be declared in namespace scope, not
in the class definition.  This restriction does not apply to partial
specializations of member templates; that is,</P>

<PRE>
    struct A {
      template&lt;class T&gt; struct B;
      template &lt;class T&gt; struct B&lt;T*&gt; { }; //<SPAN STYLE="font-family:Times"><I> well-formed</I></SPAN>
      template &lt;&gt; struct B&lt;int*&gt; { }; //<SPAN STYLE="font-family:Times"><I> ill-formed</I></SPAN>
    };
</PRE>

<P>There does not seem to be a good reason for this inconsistency.</P>

<BR><BR><HR><A NAME="730"></A><H4>730.
  
Explicit specializations of members of non-template classes
</H4><B>Section: </B>14.7.3&#160;
 [temp.expl.spec]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Bronek Kozicki
 &#160;&#160;&#160;

 <B>Date: </B>3 October, 2008<BR>




<P>The list of entities that can be explicitly specialized in
14.7.3
 [temp.expl.spec] paragraph 1 includes member templates of
class templates but not member templates of non-template classes.
This omission could lead to the conclusion that such member templates
cannot be explicitly specialized.  (Note, however, that paragraph 3
refers to &#8220;an explicit specialization for a member template of
[a] class or class template.&#8221;)</P>

<BR><BR><HR><A NAME="264"></A><H4>264.
  
Unusable template constructors and conversion functions
</H4><B>Section: </B>14.8.1&#160;
 [temp.arg.explicit]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>17 Nov 2000<BR>




<P>The note in paragraph 5 of 14.8.1
 [temp.arg.explicit] makes
clear that explicit template arguments cannot be supplied in
invocations of constructors and conversion functions because they are
called without using a name.  However, there is nothing in the current
wording of the Standard that makes declaring a constructor or
conversion operator that is unusable because of nondeduced parameters
(i.e., that would need to be specified explicitly) ill-formed.  It
would be a service to the programmer to diagnose this useless
construct as early as possible.</P>

<BR><BR><HR><A NAME="271"></A><H4>271.
  
Explicit instantiation and template argument deduction
</H4><B>Section: </B>14.8.2&#160;
 [temp.deduct]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>20 Feb 2001<BR>




<P>Nicolai Josuttis sent me an example like the following:</P>

<PRE>
    template &lt;typename RET, typename T1, typename T2&gt;
    const RET&amp; min (const T1&amp; a, const T2&amp; b)
    {
	return (a &lt; b ? a : b);
    }
    template const int&amp; min&lt;int&gt;(const int&amp;,const int&amp;);  // #1
    template const int&amp; min(const int&amp;,const int&amp;);       // #2
</PRE>

<P>Among the questions was whether explicit instantiation #2 is valid,
where deduction is required to determine the type of <TT>RET</TT>.</P>

<P>The first thing I realized when researching this is that the standard
does not really spell out the rules for deduction in declarative
contexts (friend declarations, explicit specializations, and
explicit instantiations).  For explicit instantiations,
14.7.2
 [temp.explicit] paragraph 2 does
mention deduction, but it doesn't say which set of deduction rules from
14.8.2
 [temp.deduct] should be applied.</P>

<P>Second, Nicolai pointed out that
14.7.2
 [temp.explicit] paragraph 6 says</P>

<BLOCKQUOTE>
A trailing <I>template-argument</I>
can be left unspecified in an explicit instantiation provided it can
be deduced from the type of a function parameter
(14.8.2
 [temp.deduct]).
</BLOCKQUOTE>

<P>This prohibits cases
like #2, but I believe this was not considered in the wording as there
is no reason not to include the return type in the deduction process.</P>

<P>I think there may have been some confusion because the return type is
excluded when doing deduction on a function call.  But there are
contexts where the return type is included in deduction, for example,
when taking the address of a function template specialization.</P>

<P><U>Suggested resolution</U>:</P>

<OL>

<LI>Update 14.8.2
 [temp.deduct] to include a section
"Deducing template arguments from a declaration" that describes how
deduction is done when finding a template that matches a declaration.
This should, I believe, include the return type.</LI>

<LI>Update 14.7.2
 [temp.explicit] to make reference to the new
rules in 14.8.2
 [temp.deduct] and remove the description of
the deduction details from 14.7.2
 [temp.explicit] paragraph
6.</LI>

</OL>
<BR><BR><HR><A NAME="297"></A><H4>297.
  
Which template does an explicit specialization specialize?
</H4><B>Section: </B>14.8.2&#160;
 [temp.deduct]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Andrei Iltchenko
 &#160;&#160;&#160;

 <B>Date: </B>7 Jul 2001<BR>


<P>Andrei Iltchenko points out that the standard has no wording that
defines how to determine which template is specialized by an
explicit specialization of a function template.
He suggests "template argument deduction
in such cases proceeds in the same way as when taking the address
of a function template,
which is described in 14.8.2.2
 [temp.deduct.funcaddr]."</P>

<P>John Spicer points out that the same problem exists for all
similar declarations, i.e., friend declarations and explicit
instantiation directives.  Finding a corresponding placement
<TT>operator delete</TT> may have a similar problem.</P>

<P><U>John Spicer</U>:
There are two aspects of "determining which template" is referred to by
a declaration: determining the function template associated with the
named specialization, and determining the values of the template arguments
of the specialization.</P>
<PRE>
    template &lt;class T&gt; void f(T);  #1
    template &lt;class T&gt; void f(T*); #2
    template &lt;&gt; void f(int*);
</PRE>

<P>In other words, which <TT>f</TT> is being specialized (#1 or #2)?
And then, what are the deduced template arguments?</P>

<P>14.5.6.2
 [temp.func.order] does say that partial ordering is
done in contexts such as this.
Is this sufficient, or do we need to say more about the selection of the
function template to be selected? </P>

<P>14.8.2
 [temp.deduct] probably needs a new section to cover
argument deduction for cases like this.</P>

<BR><BR><HR><A NAME="697"></A><H4>697.
  
Deduction rules apply to more than functions
</H4><B>Section: </B>14.8.2&#160;
 [temp.deduct]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Doug Gregor
 &#160;&#160;&#160;

 <B>Date: </B>6 June, 2008<BR>




<P>14.8.2
 [temp.deduct] is all about function types, but these
rules also apply, e.g., when matching a class template partial
specialization.  We should add a note stating that we could be doing
substitution into the <I>template-id</I> for a class template partial
specialization.</P>

<P><B>Additional note (August 2008):</B></P>

<P>According to 14.5.5.1
 [temp.class.spec.match] paragraph 2, argument
deduction is used to determine whether a given partial specialization
matches a given argument list.  However, there is nothing in
14.5.5.1
 [temp.class.spec.match] nor in 14.8.2
 [temp.deduct] and
its subsections that describes exactly how argument deduction is to
be performed in this case.  It would seem that more than just a note
is required to clarify this processing.</P>

<BR><BR><HR><A NAME="503"></A><H4>503.
  
Cv-qualified function types in template argument deduction
</H4><B>Section: </B>14.8.2.1&#160;
 [temp.deduct.call]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Gabriel Dos Reis
 &#160;&#160;&#160;

 <B>Date: </B>22 Feb 2005<BR>




<P>Consider the following program:</P>

<PRE>
    template &lt;typename T&gt; int ref (T&amp;)                { return 0; }
    template &lt;typename T&gt; int ref (const T&amp;)          { return 1; }
    template &lt;typename T&gt; int ref (const volatile T&amp;) { return 2; }
    template &lt;typename T&gt; int ref (volatile T&amp;)       { return 4; }

    template &lt;typename T&gt; int ptr (T*)                { return 0; }
    template &lt;typename T&gt; int ptr (const T*)          { return 8; }
    template &lt;typename T&gt; int ptr (const volatile T*) { return 16; }
    template &lt;typename T&gt; int ptr (volatile T*)       { return 32; }

    void foo() {}

    int main()
    {
        return ref(foo) + ptr(&amp;foo);
    }
</PRE>

<P>The Standard appears to specify that the value returned from
<TT>main</TT> is 2.  The reason for this result is that references and
pointers are handled differently in template argument deduction.</P>

<P>For the reference case, 14.8.2.1
 [temp.deduct.call] paragraph
3 says that &#8220;If <TT>P</TT> is a reference type, the type
referred to by <TT>P</TT> is used for type deduction.&#8221; Because
of <A HREF="
     cwg_defects.html#295">issue 295</A>, all four of the types for the
<TT>ref</TT> function parameters are the same, with no
cv-qualification; overload resolution does not find a best match among
the parameters and thus the most-specialized function is selected.</P>

<P>For the pointer type, argument deduction does not get as far as
forming a cv-qualified function type; instead, argument deduction
fails in the cv-qualified cases because of the cv-qualification
mismatch, and only the cv-unqualified version of <TT>ptr</TT> survives
as a viable function.</P>

<P>I think the choice of ignoring cv-qualifiers in the reference case
but not the pointer case is very troublesome.  The reason is that when
one considers function objects as function parameters, it introduces a
semantic difference whether the function parameter is declared a
reference or a pointer.  In all other contexts, it does not matter: a
function name decays to a pointer and the resulting semantics are the
same.</P>

<BR><BR><HR><A NAME="469"></A><H4>469.
  
Const template specializations and reference arguments
</H4><B>Section: </B>14.8.2.5&#160;
 [temp.deduct.type]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Matt Austern
 &#160;&#160;&#160;

 <B>Date: </B>19 Mar 2004<BR>




<P>Consider the following:</P>
<PRE>
	template &lt;typename T&gt; struct X {};  // #1
	template &lt;typename T&gt; struct X&lt;const T&gt;; //#2
	template struct X&lt;int&amp;&gt;; //#3
</PRE>

<P>Which specialization are we instantiating in #3?  The "obvious" answer 
is #1, because "int&amp;" doesn't have a top level cv-qualification.  
However, there's also an argument saying that we should actually be 
instantiating #2.  The argument is: int&amp; can be taken as a match for 
either one (top-level cv-qualifiers are ignored on references, so 
they're equally good), and given two equally good matches we must 
choose the more specialized one.</P>

<P>Is this a valid argument?  If so, is this behavior intentional?</P>

<P><U>John Spicer:</U>
I don't see the rationale for any choice other than #1.  While it is
true that if you attempt to apply const to a reference type it just
gets dropped, that is very different from saying that a reference type
is acceptable where a const-qualified type is required.</P>

<P><I>If</I> the type matched both templates, the const one would be
more specialized, but "int&amp;" does not match "const T".</P>

<P><U>Nathan Sidwell:</U>
thanks for bringing this one to the committee.  However this is
resolved, I'd like clarification on the followup questions in the
gcc bug report regarding deduced and non-deduced contexts and
function templates.  Here're those questions for y'all,</P>
<PRE>
template &lt;typename T&gt; void Foo (T *); // #1
template &lt;typename T&gt; void Foo (T const *); // #2
void Baz ();
Foo (Baz); // which?

template &lt;typename T&gt; T const *Foo (T *); // #1
void Baz ();
Foo (Baz); // well formed?

template &lt;typename T&gt; void Foo (T *, T const * = 0);
void Baz ();
Foo (Baz); // well formed?
</PRE>
<P>BTW, I didn't go trying to break things, I implemented the cv-qualifier
ignoring requirements and fell over this.  I could find nothing in the
standard saying 'don't do this ignoring during deduction'.</P>



<BR><BR><HR><A NAME="748"></A><H4>748.
  
Always-complete archetypes
</H4><B>Section: </B>14.10.2.1&#160;
 [temp.archetype.assemble]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Widman
 &#160;&#160;&#160;

 <B>Date: </B>28 November, 2008<BR>




<P>Suppose we have</P>

<PRE>
    template&lt;std::ObjectType T&gt;
    T* f(T* p) {
         return ++p; // Presumably ok
    }
</PRE>

<P>5.3.2
 [expr.pre.incr] paragraph 1 requires that &#8220;The
type of the operand shall be an arithmetic type or a pointer to a
completely-defined effective object type.&#8221;  At <TT>++p</TT> in
this example, the type archetype <TT>T'</TT> is considered to be
completely-defined because</P>

<BLOCKQUOTE>

A type archetype is considered to be completely defined when it is
established

</BLOCKQUOTE>

<P>(14.10.2.1
 [temp.archetype.assemble] paragraph 1) and
14.7.2
 [temp.explicit] paragraph 7 says that an archetype becomes
established when</P>

<BLOCKQUOTE>

the archetype is used in a context where a complete type is required

</BLOCKQUOTE>

<P>So far, so good.  Consider use of <TT>f(T*)</TT> with an incomplete
type, for instance:</P>

<PRE>
    struct A; // A is not defined yet.

    A* g(A* p) {
         return f(p);
    }
</PRE>

<P>During template argument deduction against the template
<TT>f(T*)</TT>, we find that there is a concept map for
<TT>std::ObjectType&lt;A&gt;</TT> because <TT>std::ObjectType</TT> is
a compiler-supported concept, and because <TT>A</TT> is an object type
(3.9
 [basic.types]), so the compiler provides the concept map
implicitly. Type deduction succeeds, but then we get an instantiation-time
error on <TT>++p</TT> because <TT>A</TT> is incomplete.</P>

<P>I see two potential solutions:</P>

<OL><LI><P>We can remove built-in operations for
ptr-to-effective-object-type, so that you would have to explicitly
require something like <TT>std::HasPreincrement&lt;T*&gt;</TT> before
using <TT>++</TT> on values of type <TT>T*</TT> in <TT>f(T*)</TT>.
Then <TT>A</TT>'s lack of completeness would be indicated when we try
to satisfy those requirements automatically (and not at instantiation
time).</P></LI>

<LI><P>Alternatively, we can introduce the notion of a
compiler-supported concept <TT>std::CompleteType&lt;T&gt;</TT>, and
amend 14.10.2.1
 [temp.archetype.assemble] so that a type archetype is only
considered to be completely-defined if it has that requirement.  This
would imply that <TT>f(T*)</TT> above is ill-formed at <TT>++p</TT>
because <TT>T</TT> would then be an incomplete effective object type;
the user could fix this by inserting <TT>requires
std::CompleteType&lt;T&gt;</TT> after the
<I>template-parameter-list</I>, and then the call <TT>f(p)</TT> would
be ill-formed because <TT>std::CompleteType&lt;A&gt;</TT> would not be
satisfied.</P></LI>

</OL>

<BR><BR><HR><A NAME="388"></A><H4>388.
  
Catching base<TT>*&amp;</TT> from a throw of derived<TT>*</TT>
</H4><B>Section: </B>15.3&#160;
 [except.handle]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>28 Oct 2002<BR>




<P>I have a question about exception handling with respect to derived to base
conversions of pointers caught by reference.</P>

<P>What should the result of this program be?</P>
<PRE>
  struct S             {};
  struct SS : public S {};

  int main()
  {
  	SS ss;
  	int result = 0;
  	try
  	{
  		throw &amp;ss; // throw object has type SS*
  		           // (pointer to derived class)
  	}
  	catch (S*&amp; rs) // (reference to pointer to base class)
  	{
  		result = 1;
  	}
  	catch (...)
  	{
  		result = 2;
  	}
  	return result;
  }
</PRE>

<P>The wording of 15.3
 [except.handle] paragraph 3
would seem to say that the catch of S*&amp; does not
match and so the catch ... would be taken.</P>

<P>All of the compilers I tried (EDG, g++, Sun, and Microsoft) used the catch
of S*&amp; though.</P>

<P>What do we think is the desired behavior for such cases?</P>

<P>My initial reaction is that this is a bug in all of these compilers, but
the fact that they all do the same thing gives me pause.</P>

<P>On a related front, if the handler changes the parameter using the
reference, what is caught by a subsequent handler?</P>
<PRE>
  extern "C" int printf(const char *, ...);
  struct S             {};
  struct SS : public S {};
  SS ss;

  int f()
  {
  	try
  	{
  		throw &amp;ss;
  	}
  	catch (S*&amp; rs) // (reference to pointer to base class)
  	{
  		rs = 0;
  		throw;
  	}
  	catch (...)
  	{
  	}
  	return 0;
  }

  int main()
  {
  	try { f(); }
  	catch (S*&amp; rs) {
  		printf("rs=%p, &amp;ss=%p\n", rs, &amp;ss);
  	}
  }
</PRE>

<P>EDG, g++, and Sun all catch the original (unmodified) value.  Microsoft
catches the modified value.  In some sense the EDG/g++/Sun behavior makes
sense because the later catch could catch the derived class instead of the
base class, which would be difficult to do if you let the catch clause
update the value to be used by a subsequent catch.</P>

<P>But on this non-pointer case, all of the compilers later catch the
modified value:</P>
<PRE>
  extern "C" int printf(const char *, ...);
  int f()
  {
  	try
  	{
  		throw 1;
  	}
  	catch (int&amp; i)
  	{
  		i = 0;
  		throw;
  	}
  	catch (...)
  	{
  	}
  	return 0;
  }

  int main()
  {
  	try { f(); }
  	catch (int&amp; i) {
  		printf("i=%p\n", i);
  	}
  }
</PRE>

<P>To summarize:</P>
<OL>
<LI>Should "base*const&amp;" be able to catch a "derived*"? 
The current standard
seems to say "no" but parallels to how calls work, and existing practice,
suggest that the answer should be "yes".</LI>

<LI>Should "base*&amp;" be able to catch a "derived*".  Again,
the standard seems
seems to say "no".  Parallels to how calls work still suggest "no", but
existing practice suggests "yes".</LI>

<LI>If either of the above is "yes", what happens if you modify the pointer
referred to by the reference.  This requires a cast to remove const for
case #2.</LI>

<LI>On a related front, if you catch
"derived*&amp;" when a "derived*" is thrown,
what happens if you modify the pointer referred to by the reference?
EDG/g++/Sun still don't modify the underlying value that would be
caught by a rethrow in this case.  This case seems like it should be
the same as the "int&amp;" example above, but is not on the three compilers
mentioned.</LI>
</OL>

<BR><BR><HR><A NAME="729"></A><H4>729.
  
Qualification conversions and handlers of reference-to-pointer type
</H4><B>Section: </B>15.3&#160;
 [except.handle]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>6 October, 2008<BR>


<P>Given the following example:</P>

<PRE>
    int f() {
        try { /* ... */ }
        catch(const int*&amp;) {
            return 1;
        }
        catch(int*&amp;) {
            return 2;
        }
        return 3;
    }
</PRE>

<P>can <TT>f()</TT> return <TT>2</TT>?  That is, does an
<TT>int*</TT> exception object match a <TT>const int*&amp;</TT>
handler?</P>

<P>According to 15.3
 [except.handle] paragraph 3, it does not:</P>

<BLOCKQUOTE>

<P>A <I>handler</I> is a match for an exception object of type
<TT>E</TT> if</P>

<UL>
<LI><P>The <I>handler</I> is of type <I>cv</I> <TT>T</TT> or <I>cv</I>
<TT>T&amp;</TT> and <TT>E</TT> and <TT>T</TT> are the same type
(ignoring the top-level <I>cv-qualifier</I>s), or</P></LI>

<LI><P>the <I>handler</I> is of type <I>cv</I> <TT>T</TT> or <I>cv</I>
<TT>T&amp;</TT> and <TT>T</TT> is an unambiguous public base class of
<TT>E</TT>, or</P></LI>

<LI><P>the handler is of type <I>cv1</I> <TT>T*</TT> <I>cv2</I> and
<TT>E</TT> is a pointer type that can be converted to the type of the
handler by either or both of</P>

<UL>
<LI><P>a standard pointer conversion (4.10
 [conv.ptr]) not
involving conversions to pointers to private or protected or ambiguous
classes</P></LI>

<LI><P>a qualification conversion</P></LI>
</UL></LI>

<LI><P>the <I>handler</I> is a pointer or pointer to member type and
<TT>E</TT> is <TT>std::nullptr_t</TT>.</P></LI>

</UL>

</BLOCKQUOTE>

<P>Only the third bullet allows qualification conversions, but
only the first bullet applies to a <I>handler</I> of
reference-to-pointer type.  This is consistent with how other
reference bindings work; for example, the following is ill-formed:</P>

<PRE>
    int* p;
    const int*&amp; r = p;
</PRE>

<P>(The consistency is not complete; the reference binding would be
permitted if <TT>r</TT> had type <TT>const int* const &amp;</TT>, but
a handler of that type would still not match an <TT>int*</TT>
exception object.)</P>

<P>However, implementation practice seems to be in the other
direction; both EDG and g++ do match an <TT>int*</TT> with a <TT>const
int*&amp;</TT>, and the Microsoft compiler issues an error for the
presumed hidden handler in the code above. Should the Standard be
changed to reflect existing practice?</P>

<BR><BR><HR><A NAME="92"></A><H4>92.
  
Should exception specifications be part of the type system?
</H4><B>Section: </B>15.4&#160;
 [except.spec]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jonathan Schilling
 &#160;&#160;&#160;

 <B>Date: </B>2 Feb 1999<BR>


    
<P>It was tentatively agreed at the Santa Cruz meeting
that exception specifications
should fully participate in the type system.  This change would
address gaps in the current static checking of exception specifications
such as</P>

<PRE>
    void (*p)() throw(int);
    void (**pp)() throw() = &amp;p;   // not currently an error
</PRE>
    
<P>This is such a major change that it deserves to be a separate
issue.</P>

<P>See also issues <A HREF="
     cwg_defects.html#25">25</A>,
<A HREF="
     cwg_defects.html#87">87</A>, and
<A HREF="
     cwg_closed.html#133">133</A>.</P>
<BR><BR><HR><A NAME="595"></A><H4>595.
  
Exception specifications in templates instantiated from class bodies
</H4><B>Section: </B>15.4&#160;
 [except.spec]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>7 September 2006<BR>


<P>A type used in an exception specification must be complete
(15.4
 [except.spec] paragraph 2).  The resolution of
<A HREF="
     cwg_defects.html#437">issue 437</A> stated that a class type
appearing in an exception specification inside its own
<I>member-specification</I> is considered to be complete.  Should
this also apply to exception specifications in class templates
instantiated because of a reference inside
the <I>member-specification</I> of a class?  For example,</P>

<PRE>
    template&lt;class T&gt; struct X {
        void f() throw(T) {}
    };

    struct S {
        X&lt;S&gt; xs;
    };
</PRE>

<BR><BR><HR><A NAME="219"></A><H4>219.
  
Cannot defend against destructors that throw exceptions
</H4><B>Section: </B>15.5.1&#160;
 [except.terminate]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Herb Sutter
 &#160;&#160;&#160;

 <B>Date: </B>31 Mar 2000<BR>




<P>Destructors that throw can easily cause programs to terminate,
with no possible defense.  Example: Given</P>

<PRE>
    struct XY { X x; Y y; };
</PRE>

<P>Assume that <TT>X::~X()</TT> is the only destructor in the entire
program that can throw. Assume further that <TT>Y</TT> construction is
the only other operation in the whole program that can throw. Then
<TT>XY</TT> cannot be used safely, in any context whatsoever, period
&#8212; even simply declaring an <TT>XY</TT> object can crash the
program:</P>

<PRE>
    XY xy; // construction attempt might terminate program:
	   //   1. construct x -- succeeds
	   //   2. construct y -- fails, throws exception
	   //   3. clean up by destroying x -- fails, throws exception,
	   //      but an exception is already active, so call 
	   //      std::terminate() (oops)
	   // there is no defense
</PRE>

So it is highly dangerous to have even one destructor that could throw.

<P>Suggested Resolution:</P>

<P>Fix the above problem in one of the following two ways. I prefer
the first.</P>

<OL>

<LI>We already have text that specifies that any destructor operation in 
the standard library (presumably including the destructors of UDTs used in 
containers or as predicates, etc.) may not throw. There is good reason to 
widen this injunction to specify that destructors may never throw at all.
(I realize this would render existing programs nonconforming if they did
do this, but it's unsafe anyway.)</LI>

<LI>Specify what happens in the above case so that
<TT>std::terminate()</TT> won't be called.</LI>

</OL>

<P><U>Fergus Henderson</U>: I disagree.  Code using <TT>XY</TT> may
well be safe, if <TT>X::~X()</TT> only throws if
<TT>std::uncaught_exception()</TT> is <TT>false</TT>.</P>

<P>I think the current exception handling scheme in C++ is certainly
flawed, but the flaws are IMHO design flaws, not minor technical
defects, and I don't think they can be solved by minor tweaks to the
existing design.  I think that at this point it is probably better to
keep the standard stable, and learn to live with the existing flaws,
rather than trying to solve them via TC.</P>

<P><U>Bjarne Stroustrup</U>: I strongly prefer to have the call to
<TT>std::terminate()</TT> be conforming. I see <TT>std::terminate()</TT> as a
proper way to blow away "the current mess" and get to the next level
of error handling. I do not want that escape to be non-conforming
&#8212; that would imply that programs relying on a error handling
based on serious errors being handled by terminating a process (which
happens to be a C++ program) in <TT>std::terminate()</TT> becomes
non-conforming. In many systems, there are &#8212; and/or should be
&#8212; error-handling and recovery mechanisms beyond what is offered
by a single C++ program.</P>

<P><U>Andy Koenig</U>: If we were to prohibit writing a destructor
that can throw, how would I solve the following problem?</P>

<P>I want to write a class that does buffered output.  Among the
other properties of that class is that destroying an object of
that class writes the last buffer on the output device before
freeing memory.</P>

<P>What should my class do if writing that last buffer indicates a
hardware output error?  My user had the option to flush the last
buffer explicitly before destroying the object, but didn't do so, and
therefore did not anticipate such a problem.  Unfortunately, the
problem happened anyway.  Should I be required to suppress this
error indication anyway?  In all cases?</P>

<P><U>Herb Sutter</U> (June, 2007): IMO, it's fine to suppress
it.  The user had the option of flushing the buffer and thus
being notified of the problem and chose not to use it.  If the
caller didn't flush, then likely the caller isn't ready for an
exception from the destructor, either.  You could also put an
assert into the destructor that would trigger if <TT>flush()</TT>
had not been called, to force callers to use the interface that
would report the error.  
</P>

<P>In practice, I would rather thrown an exception, even at the risk
of crashing the program if we happen to be in the middle of stack
unwinding.  The reason is that the program would crash only if a
hardware error occurred in the middle of cleaning up from some other
error that was in the process of being handled.  I would rather have
such a bizarre coincidence cause a crash, which stands a chance of
being diagnosed later, than to be ignored entirely and leave the
system in a state where the ignore error could cause other trouble
later that is even harder to diagnose.</P>

<P>If I'm not allowed to throw an exception when I detect this problem,
what are my options?</P>

<P><U>Herb Sutter</U>: I understand that some people might feel that
"a failed dtor during stack unwinding is preferable in certain cases"
(e.g., when recovery can be done beyond the scope of the program), but
the problem is "says who?"  It is the application program that should
be able to decide whether or not such semantics are correct for it,
and the problem here is that with the status quo a program cannot
defend itself against a <TT>std::terminate()</TT> &#8212; period. The
lower-level code makes the decision for everyone. In the original
example, the mere existence of an <TT>XY</TT> object puts at risk
every program that uses it, whether <TT>std::terminate()</TT> makes sense
for that program or not, and there is no way for a program to protect
itself.</P>

<P>That the "it's okay if the process goes south should a rare
combination of things happen" decision should be made by lower-level
code (e.g., <TT>X</TT> dtor) for all apps that use it, and which
doesn't even understand the context of any of the hundreds of apps
that use it, just cannot be correct.</P>

<BR><BR><HR><A NAME="596"></A><H4>596.
  
Replacing an exception object
</H4><B>Section: </B>15.5.2&#160;
 [except.unexpected]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Alisdair Meredith
 &#160;&#160;&#160;

 <B>Date: </B>12 September 2006<BR>


<P>When a function throws an exception that is not in its
<I>exception-specification</I>, <TT>std::unexpected()</TT> is called.
According to 15.5.2
 [except.unexpected] paragraph 2,</P>

<BLOCKQUOTE>

If [<TT>std::unexpected()</TT>] throws or rethrows an exception that
the <I>exception-specification</I> does not allow then the following
happens: If the <I>exception-specification</I> does not include the class
<TT>std::bad_exception</TT> (18.7.2.1
 [bad.exception]) then
the function <TT>std::terminate()</TT> is called, otherwise the thrown
exception is replaced by an implementation-defined object of the type
<TT>std::bad_exception,</TT> and the search for another handler will
continue at the call of the function
whose <I>exception-specification</I> was violated.

</BLOCKQUOTE>

<P>The &#8220;replaced by&#8221; wording is imprecise and undefined.
For example, does this mean that the destructor is called for the
existing exception object, or is it simply abandoned?  Is the
replacement <I>in situ</I>, so that a pointer to the existing
exception object will now point to the <TT>std::bad_exception</TT>
object?</P>

<P><U>Mike Miller</U>: The call to <TT>std::unexpected()</TT> is
not described as analogous to invoking a handler, but if it were,
that would resolve this question; it is clearly specified what
happens to the previous exception object when a new exception is
thrown from a handler (15.1
 [except.throw] paragraph 4).</P>

<P>This approach would also clarify other questions that have been
raised regarding the requirements for stack unwinding.  For
example, 15.5.1
 [except.terminate] paragraph 2 says that</P>

<BLOCKQUOTE>

In the situation where no matching handler is found, it is
implementation-defined whether or not the stack is unwound before
<TT>std::terminate()</TT> is called.

</BLOCKQUOTE>

<P>This requirement could be viewed as in conflict with the statement
in 15.5.2
 [except.unexpected] paragraph 1 that</P>

<BLOCKQUOTE>

If a function with an <I>exception-specification</I> throws an exception that
is not listed in the <I>exception-specification</I>, the function
<TT>std::unexpected()</TT> is called (18.7.2
 [exception.unexpected])
immediately after completing the stack unwinding for the former
function.

</BLOCKQUOTE>

<P>If it is implementation-defined whether stack unwinding occurs before
calling <TT>std::terminate()</TT> and <TT>std::unexpected()</TT> is
called only after doing stack unwinding, does that mean that it is
implementation-defined whether <TT>std::unexpected()</TT> is called
if there is ultimately no handler found?</P>

<P>Again, if invoking <TT>std::unexpected()</TT> were viewed as
essentially invoking a handler, the answer to this would be clear,
because unwinding occurs before invoking a handler.</P>

<BR><BR><HR><A NAME="268"></A><H4>268.
  
Macro name suppression in rescanned replacement text
</H4><B>Section: </B>16.3.4&#160;
 [cpp.rescan]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Bjarne Stroustrup
 &#160;&#160;&#160;

 <B>Date: </B>18 Jan 2001<BR>




<P>It is not clear from the Standard what the result of the
following example should be:</P>

<BLOCKQUOTE>
<PRE>
#define NIL(xxx) xxx
#define G_0(arg) NIL(G_1)(arg)
#define G_1(arg) NIL(arg)
G_0(42)
</PRE>
</BLOCKQUOTE>

<P>The relevant text from the Standard is found in
16.3.4
 [cpp.rescan] paragraph 2:</P>

<BLOCKQUOTE>

If the name of the macro being replaced is found during this scan of
the replacement list (not including the rest of the source file's
preprocessing tokens), it is not replaced. Further, if any nested
replacements encounter the name of the macro being replaced, it is not
replaced. These nonreplaced macro name preprocessing tokens are no
longer available for further replacement even if they are later
(re)examined in contexts in which that macro name preprocessing token
would otherwise have been replaced.

</BLOCKQUOTE>

<P>The sequence of expansion of <TT>G0(42)</TT> is as follows:</P>

<BLOCKQUOTE>
<PRE>
G0(42)
NIL(G_1)(42)
G_1(42)
NIL(42)
</PRE>
</BLOCKQUOTE>

<P>The question is whether the use of <TT>NIL</TT> in the last
line of this sequence qualifies for non-replacement under the
cited text.  If it does, the result will be <TT>NIL(42)</TT>.  If
it does not, the result will be simply <TT>42</TT>.</P>

<P>The original intent of the J11 committee in this text was
that the result should be <TT>42</TT>, as demonstrated by the
original pseudo-code description of the replacement algorithm
provided by Dave Prosser, its author.

The English description,
however, omits some of the subtleties of the pseudo-code and
thus arguably gives an incorrect answer for this case.</P>

<P><U>Suggested resolution (Mike Miller)</U>: Replace the cited
paragraph with the following:</P>

<BLOCKQUOTE>

<P>As long as the scan involves only preprocessing tokens from
a given macro's replacement list, or tokens resulting from a
replacement of those tokens, an occurrence of the macro's name
will not result in further replacement, even if it is later
(re)examined in contexts in which that macro name preprocessing
token would otherwise have been replaced.</P>

<P>Once the scan reaches the preprocessing token following a
macro's replacement list &#8212; including as part of the
argument list for that or another macro &#8212; the macro's
name is once again available for replacement.  [<I>Example:</I></P>

<PRE>
    #define NIL(xxx) xxx
    #define G_0(arg) NIL(G_1)(arg)
    #define G_1(arg) NIL(arg)
    G_0(42)                         // result is 42, not NIL(42)
</PRE>

<P>The reason that <TT>NIL(42)</TT> is replaced is that <TT>(42)</TT>
comes from outside the replacement list of <TT>NIL(G_1)</TT>, hence
the occurrence of <TT>NIL</TT> within the replacement list for
<TT>NIL(G_1)</TT> (via the replacement of <TT>G_1(42)</TT>) is not
marked as nonreplaceable.  <I>&#8212;end example</I>]</P>

</BLOCKQUOTE>

<P>(Note: The resolution of this issue must be coordinated with
J11/WG14.)</P>

<P><B>Notes (via Tom Plum) from April, 2004 WG14 Meeting:</B></P>

<P>Back in the 1980's it was understood by several WG14 people
that there were tiny differences between the "non-replacement"
verbiage and the attempts to produce pseudo-code.  The
committee's decision was that no realistic programs "in the wild"
would venture into this area, and trying to reduce the
uncertainties is not worth the risk of changing conformance
status of implementations or programs.</P>

<BR><BR><HR><A NAME="745"></A><H4>745.
  
Effect of ill-formedness resulting from <TT>#error</TT>
</H4><B>Section: </B>16.5&#160;
 [cpp.error]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Clark Nelson
 &#160;&#160;&#160;

 <B>Date: </B>13 November, 2008<BR>


<P>C99 is very clear that a <TT>#error</TT> directive causes a translation
to fail: Clause 4 paragraph 4 says,</P>

<BLOCKQUOTE>

The implementation shall not successfully translate a preprocessing
translation unit containing a <TT>#error</TT> preprocessing directive
unless it is part of a group skipped by conditional inclusion.

</BLOCKQUOTE>

<P>C++, on the other hand, simply says that a <TT>#error</TT> directive
&#8220;renders the program ill-formed&#8221; (16.5
 [cpp.error]),
and the only requirement for an ill-formed program is that a diagnostic
be issued; the translation may continue and succeed.  (Noted in passing:
if this difference between C99 and C++ is addressed, it would be helpful
for synchronization purposes in other contexts as well to introduce the
term &#8220;preprocessing translation unit.&#8221;)</P>

<BR><BR><HR><A NAME="223"></A><H4>223.
  
The meaning of deprecation
</H4><B>Section: </B>D&#160;
 [depr]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>19 Apr 2000<BR>


<P>During the discussion of issues <A HREF="
     cwg_closed.html#167">167</A> and
<A HREF="
     cwg_closed.html#174">174</A>, it became apparent that there was no
consensus on the meaning of deprecation.  Some thought that
deprecating a feature reflected an intent to remove it from
the language.  Others viewed it more as an encouragement to
programmers not to use certain constructs, even though they might be
supported in perpetuity.</P>

<P>There is a formal-sounding definition of deprecation in Annex
D
 [depr] paragraph 2:

<BLOCKQUOTE>

deprecated is defined as: Normative for the current edition of the
Standard, but not guaranteed to be part of the Standard in future
revisions.

</BLOCKQUOTE>

However, this definition would appear to say that any
non-deprecated feature <I>is</I> "guaranteed to be part of the
Standard in future revisions."  It's not clear that that implication
was intended, so this definition may need to be amended.
</P>

<P>This issue is intended to provide an avenue for discussing and
resolving those questions, after which the original issues may be
reopened if that is deemed desirable.</P>
<BR><BR><BR><BR></BODY>
</HTML>
