This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


2264. Memberwise copying with indeterminate value

Section: 11.4.5.3  [class.copy.ctor]     Status: drafting     Submitter: Hubert Tong     Date: 2016-05-06

It appears that the following example may have unwanted undefined behavior in C++, although not in C:

  struct A { int x, y; };
  A passthrough(A a) { return a; }
  int main(void) {
   A a;
   a.x = 0;
   return passthrough(a).x;
  }

The default memberwise copying operation is not specified to be done in a way that is insensitive to indeterminate values.