The implicitly-declared copy constructor and
implicitly-declared copy assignment operator
cannot make a copy of a volatile lvalue
. For example, the following is valid in ISO C:
struct X { int i; };
volatile struct X x1 = {0};
struct X x2 = x1; struct X x3;
x3 = x1;
Rationale:
Several alternatives were debated at length
. Changing the parameter to
volatile
const
X&
would greatly complicate the generation of
efficient code for class objects
. Discussion of
providing two alternative signatures for these
implicitly-defined operations raised
unanswered concerns about creating
ambiguities and complicating
the rules that specify the formation of
these operators according to the bases and
members
. Effect on original feature:
Deletion of semantically well-defined feature
. Difficulty of converting:
Semantic transformation
. If volatile semantics are required for the copy,
a user-declared constructor or assignment must
be provided
. If non-volatile semantics are required,
an explicit
const_cast
can be used
.