Skip to content

Commit 2e92639

Browse files
committed
P2647R1 Permitting static constexpr variables in constexpr functions
Fixes NB GB 048 (C++23 CD).
1 parent f810445 commit 2e92639

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎source/expressions.tex‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7367,7 +7367,18 @@
73677367
a control flow that passes through
73687368
a declaration of a variable with
73697369
static\iref{basic.stc.static} or
7370-
thread\iref{basic.stc.thread} storage duration;
7370+
thread\iref{basic.stc.thread} storage duration,
7371+
unless that variable is usable in constant expressions;
7372+
\begin{example}
7373+
\begin{codeblock}
7374+
constexpr char test() {
7375+
static const int x = 5;
7376+
static constexpr char c[] = "Hello World";
7377+
return *(c + x);
7378+
}
7379+
static_assert(' ' == test());
7380+
\end{codeblock}
7381+
\end{example}
73717382

73727383
\item
73737384
an invocation of a non-constexpr function;

‎source/preprocessor.tex‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@
18011801
\defnxname{cpp_char8_t} & \tcode{202207L} \\ \rowsep
18021802
\defnxname{cpp_concepts} & \tcode{202002L} \\ \rowsep
18031803
\defnxname{cpp_conditional_explicit} & \tcode{201806L} \\ \rowsep
1804-
\defnxname{cpp_constexpr} & \tcode{202207L} \\ \rowsep
1804+
\defnxname{cpp_constexpr} & \tcode{202211L} \\ \rowsep
18051805
\defnxname{cpp_constexpr_dynamic_alloc} & \tcode{201907L} \\ \rowsep
18061806
\defnxname{cpp_constexpr_in_decltype} & \tcode{201711L} \\ \rowsep
18071807
\defnxname{cpp_consteval} & \tcode{201811L} \\ \rowsep

0 commit comments

Comments
 (0)