A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.github.io/CWG/issues/2004.html below:

CWG Issue 2004

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

2025-04-13

2004. Unions with mutable members in constant expressionsSection: 7.7  [expr.const]     Status: CD4     Submitter: Richard Smith     Date: 2014-09-16

[Moved to DR at the October, 2015 meeting.]

In an example like

  union U { int a; mutable int b; };
  constexpr U u1 = {1};
  int k = (u1.b = 2);
  constexpr U u2 = u1; // ok!!

The initialization of u2 is not disqualified by the current wording of the Standard because the copy is done via the object representation, not formally involving an lvalue-to-rvalue conversion. A restriction should be added to 7.7 [expr.const] forbidding the evaluation of a defaulted copy/move construction/assignment on a class type that has any variant mutable subobjects.

Proposed resolution (May, 2015):

  1. Add the following bullet after bullet 3.1 of 9.2.6 [dcl.constexpr]:

  2. The definition of a constexpr function shall satisfy the following constraints:

  3. Add the following bullet after bullet 4.1 of 9.2.6 [dcl.constexpr]

  4. The definition of a constexpr constructor shall satisfy the following constraints:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4