Movatterモバイル変換


[0]ホーム

URL:


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

2025-12-20


2531. Static data members redeclared as constexpr

Section:9.2.6  [dcl.constexpr]    Status:CD7    Submitter:Davis Herring    Date:2022-02-16

[Accepted as a DR at the November, 2023 meeting.]

C++17 made constexpr static data members implicitly inline(9.2.6 [dcl.constexpr] paragraph 1):

A function or static data member declared with theconstexpr orconsteval specifier is implicitly an inline function or variable(9.2.8 [dcl.inline]).

However, that makes the following well-formed C++14 program ill-formed,no diagnostic required, per 9.2.8 [dcl.inline] paragraph 5:

If a function or variable with external or module linkage is declaredinline in one definition domain, an inline declaration of it shall bereachable from the end of every definition domain in which it isdeclared; no diagnostic is required.
  // x.hh  struct X {    static const int x;  };  // TU 1  #include "x.hh"  constexpr int X::x{};  // TU 2  #include "x.hh"  int main() { return !&X::x; }

Proposed resolution (reviewed by CWG 2023-02-07, approved by CWG 2023-11-07):

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

A function or static data member declared with theconstexpr orconsteval specifieron its first declarationis implicitly an inline function or variable(9.2.8 [dcl.inline]).

Drafting note: Functions must be declaredconstexpr onevery declaration if on any, so this isn't a change for them.




[8]ページ先頭

©2009-2026 Movatter.jp