File tree Expand file tree Collapse file tree 3 files changed +25
-21
lines changed Expand file tree Collapse file tree 3 files changed +25
-21
lines changed Original file line number Diff line number Diff line change 783
783
784
784
\item
785
785
if the function is a constructor or destructor,
786
- its class shall not have any virtual base classes;
787
-
788
- \item
789
- its \grammarterm {function-body} shall not enclose\iref {stmt.pre }
790
- \begin {itemize }
791
- \item a \tcode {goto} statement,
792
- \item a label with an \grammarterm {identifier}\iref {stmt.label },
793
- \item a definition of a variable
794
- of non-literal type or
795
- of static or thread storage duration.
796
- \end {itemize }
797
- \begin {note }
798
- A \grammarterm {function-body} that is \tcode {= delete} or \tcode {= default}
799
- encloses none of the above.
800
- \end {note }
786
+ its class shall not have any virtual base classes.
801
787
\end {itemize }
802
788
803
789
\begin {example }
811
797
x = -x;
812
798
return x; // OK
813
799
}
814
- constexpr int first(int n) {
815
- static int value = n; // error: variable has static storage duration
816
- return value;
800
+ constexpr int constant_non_42(int n) { // OK
801
+ if (n == 42) {
802
+ static int value = n;
803
+ return value;
804
+ }
805
+ return n;
817
806
}
818
807
constexpr int uninit() {
819
808
struct { int a; } s;
892
881
constexpr D() : B(global) { } // ill-formed, no diagnostic required
893
882
// lvalue-to-rvalue conversion on non-constant \tcode {global}
894
883
};
884
+
885
+ constexpr int f(int x) {
886
+ static int n = x;
887
+ return n + x; // ill-formed, no diagnostic required
888
+ // all calls reach the static variable declaration
889
+ }
895
890
\end {codeblock }
896
891
\end {example }
897
892
Original file line number Diff line number Diff line change 7080
7080
function\iref {dcl.constexpr } that is being evaluated as part
7081
7081
of $ E$ ;
7082
7082
7083
+ \item
7084
+ a control flow that passes through
7085
+ a declaration of a variable with
7086
+ static\iref {basic.stc.static } or
7087
+ thread\iref {basic.stc.thread } storage duration;
7088
+
7083
7089
\item
7084
7090
an invocation of a non-constexpr function;
7085
7091
\begin {footnote }
7249
7255
that would throw an exception;
7250
7256
7251
7257
\item
7252
- an \grammarterm {asm-declaration}\iref {dcl.asm }; or
7258
+ an \grammarterm {asm-declaration}\iref {dcl.asm };
7259
+
7260
+ \item
7261
+ an invocation of the \tcode {va_arg} macro\iref {cstdarg.syn }; or
7253
7262
7254
7263
\item
7255
- an invocation of the \tcode {va_arg} macro \iref {cstdarg.syn }.
7264
+ a \tcode {goto} statement \iref {stmt.goto }.
7256
7265
\end {itemize }
7257
7266
7258
7267
If $ E$ satisfies the constraints of a core constant expression, but
Original file line number Diff line number Diff line change 1765
1765
\defnxname {cpp_char8_t} & \tcode {201811L} \\ \rowsep
1766
1766
\defnxname {cpp_concepts} & \tcode {201907L} \\ \rowsep
1767
1767
\defnxname {cpp_conditional_explicit} & \tcode {201806L} \\ \rowsep
1768
- \defnxname {cpp_constexpr} & \tcode {201907L } \\ \rowsep
1768
+ \defnxname {cpp_constexpr} & \tcode {202110L } \\ \rowsep
1769
1769
\defnxname {cpp_constexpr_dynamic_alloc} & \tcode {201907L} \\ \rowsep
1770
1770
\defnxname {cpp_constexpr_in_decltype} & \tcode {201711L} \\ \rowsep
1771
1771
\defnxname {cpp_consteval} & \tcode {201811L} \\ \rowsep
You can’t perform that action at this time.
0 commit comments