diff options
author | Jason Merrill <jason@redhat.com> | 2023-02-06 15:08:17 -0800 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2023-05-10 11:09:56 -0400 |
commit | 8d46516a61a83d24ba89086071f65a194d82ce4e (patch) | |
tree | 57f0d3898eb405b45f999ffe7e9194c58afeae66 /gcc/testsuite/g++.dg | |
parent | 688fdde2f18e3318ef7e9889fdb9b239b905dfc7 (diff) | |
download | gcc-8d46516a61a83d24ba89086071f65a194d82ce4e.zip gcc-8d46516a61a83d24ba89086071f65a194d82ce4e.tar.gz gcc-8d46516a61a83d24ba89086071f65a194d82ce4e.tar.bz2 |
c++: be stricter about constinit [CWG2543]
DR 2543 clarifies that constinit variables should follow the language, and
diagnose non-constant initializers (according to [expr.const]) even if they
can actually initialize the variables statically.
DR 2543
gcc/cp/ChangeLog:
* constexpr.cc (cxx_eval_outermost_constant_expr): Preserve
TARGET_EXPR flags.
(potential_constant_expression_1): Check TARGET_EXPR_ELIDING_P.
* typeck2.cc (store_init_value): Diagnose constinit sooner.
gcc/testsuite/ChangeLog:
* g++.dg/DRs/dr2543.C: New test.
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r-- | gcc/testsuite/g++.dg/DRs/dr2543.C | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/DRs/dr2543.C b/gcc/testsuite/g++.dg/DRs/dr2543.C new file mode 100644 index 0000000..87512d3 --- /dev/null +++ b/gcc/testsuite/g++.dg/DRs/dr2543.C @@ -0,0 +1,5 @@ +// CWG 2543 +// { dg-do compile { target c++20 } } + +float f; +constinit int * pi = (int*) &f; // { dg-error "constant" } reinterpret_cast, not constant-initialized |