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 7089
7089
function\iref {dcl.constexpr } that is being evaluated as part
7090
7090
of $ E$ ;
7091
7091
7092
+ \item
7093
+ a control flow that passes through
7094
+ a declaration of a variable with
7095
+ static\iref {basic.stc.static } or
7096
+ thread\iref {basic.stc.thread } storage duration;
7097
+
7092
7098
\item
7093
7099
an invocation of a non-constexpr function;
7094
7100
\begin {footnote }
7263
7269
that would throw an exception;
7264
7270
7265
7271
\item
7266
- an \grammarterm {asm-declaration}\iref {dcl.asm }; or
7272
+ an \grammarterm {asm-declaration}\iref {dcl.asm };
7273
+
7274
+ \item
7275
+ an invocation of the \tcode {va_arg} macro\iref {cstdarg.syn }; or
7267
7276
7268
7277
\item
7269
- an invocation of the \tcode {va_arg} macro \iref {cstdarg.syn }.
7278
+ a \keyword {goto} statement \iref {stmt.goto }.
7270
7279
\end {itemize }
7271
7280
7272
7281
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