Created on 2022-02-16.00:00:00 last changed 7 months ago
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 the constexpr or consteval specifier on its first declaration is implicitly an inline function or variable (9.2.8 [dcl.inline]).
Drafting note: Functions must be declared constexpr on every declaration if on any, so this isn't a change for them.
[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 the constexpr or consteval 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 declared inline in one definition domain, an inline declaration of it shall be reachable from the end of every definition domain in which it is declared; 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; }
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-04-05 21:43:46 | admin | set | status: dr -> drwp |
2023-12-19 10:15:28 | admin | set | status: ready -> dr |
2023-11-08 05:03:56 | admin | set | status: review -> ready |
2023-02-10 23:01:52 | admin | set | status: tentatively ready -> review |
2023-02-08 03:23:14 | admin | set | status: open -> tentatively ready |
2022-02-18 07:47:23 | admin | set | messages: + msg6731 |
2022-02-16 00:00:00 | admin | create |