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

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

 <B>Submitter: </B>2016-01-09
 &#160;&#160;&#160;

 <B>Date: </B>Vinny Romano<BR>




<P>Subclause 9.6.2 [<A href="https://wg21.link/dcl.fct.def.default#1">dcl.fct.def.default</A>] paragraph 1 specifies:</P>

<BLOCKQUOTE>

A function that is explicitly defaulted shall
<UL>
<LI>...</LI>
<LI>have the same declared function type (except for possibly
differing <I>ref-qualifier</I>s and except that in the case of a copy
constructor or copy assignment operator, the parameter type may be
&#8220;reference to non-const <TT>T</TT>&#8221;, where <TT>T</TT> is
the name of the member function's class) as if it had been implicitly
declared,</LI>
<LI>...</LI>
</UL>

</BLOCKQUOTE>

<P>Therefore, the following code is ill-formed:</P>

<PRE>
  struct S
  {
   int i;
   S(const S&amp;) = default;
   S(const volatile S&amp;) = default; //<SPAN CLASS="cmnt"> ill-formed</SPAN>
  };

  volatile S s1;
  S s2(s1);
</PRE>

<P>However, C.7.7 [<A href="https://wg21.link/diff.class#2">diff.class</A>] paragraph 2 mentions the ability
to default such a constructor:</P>

<BLOCKQUOTE>

If volatile semantics are required for the copy, a user-declared
constructor or assignment must be provided. [ <I>Note:</I> This
user-declared constructor may be explicitly defaulted. &#8212;<I>end
note</I>]

</BLOCKQUOTE>

<P><B>Notes from the November, 2016 meeting:</B></P>

<P>This issue is to be resolved editorially and is placed in "review'
status until the corresponding change appers in a working draft.</P>

<P><B>Additional note (February, 2022):</B></P>

<P>The change has been applied editorially with commit
<A HREF="https://github.com/cplusplus/draft/commit/219538a7be4f3e71f05070d1a52aa7150505e732">219538</A>.</P>

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