Title
Copying volatile objects
Status
cd6
Section
9.5.2 [dcl.fct.def.default]
Submitter
2016-01-09

Created on 2017-02-06.00:00:00 last changed 27 months ago

Messages

Date: 2022-02-15.00:00:00

Additional note (February, 2022):

The change has been applied editorially with commit 219538.

Date: 2016-11-15.00:00:00

Notes from the November, 2016 meeting:

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

Date: 2022-02-18.07:47:23

Subclause 9.5.2 [dcl.fct.def.default] paragraph 1 specifies:

A function that is explicitly defaulted shall
  • ...
  • have the same declared function type (except for possibly differing ref-qualifiers and except that in the case of a copy constructor or copy assignment operator, the parameter type may be “reference to non-const T”, where T is the name of the member function's class) as if it had been implicitly declared,
  • ...

Therefore, the following code is ill-formed:

  struct S
  {
   int i;
   S(const S&) = default;
   S(const volatile S&) = default; // ill-formed
  };

  volatile S s1;
  S s2(s1);

However, C.7.7 [diff.class] paragraph 2 mentions the ability to default such a constructor:

If volatile semantics are required for the copy, a user-declared constructor or assignment must be provided. [ Note: This user-declared constructor may be explicitly defaulted. —end note]
History
Date User Action Args
2022-09-25 18:08:42adminsetstatus: review -> cd6
2022-02-18 07:47:23adminsetmessages: + msg6712
2018-02-27 00:00:00adminsetmessages: + msg5883
2018-02-27 00:00:00adminsetstatus: open -> review
2017-02-06 00:00:00admincreate