A RetroSearch Logo

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

Search Query:

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

CWG Issue 1911

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

1911. constexpr constructor with non-literal base classSection: 9.2.6  [dcl.constexpr]     Status: CD4     Submitter: Richard Smith     Date: 2014-04-13

[Moved to DR at the November, 2014 meeting.]

An example like

  struct X {
    std::unique_ptr<int> p;
    constexpr X() { }
  };

is ill-formed because the X constructor cannot be used in a constant expression, because a constant expression cannot construct an object of a non-literal type like unique_ptr. This prevents use of something like

  X x;

to guarantee constant-initialization.

Proposed resolution (June, 2014):

Change 9.2.6 [dcl.constexpr] paragraph 5 as follows:

For a non-template, non-defaulted constexpr function or a non-template, non-defaulted, non-inheriting constexpr constructor, if no argument values exist such that an invocation of the function or constructor could be an evaluated subexpression of a core constant expression (7.7 [expr.const]), or, for a constructor, a constant initializer for some object (6.9.3.2 [basic.start.static]), the program is ill-formed; no diagnostic required.

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