]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: be stricter about constinit [CWG2543]
authorJason Merrill <jason@redhat.com>
Mon, 6 Feb 2023 23:08:17 +0000 (15:08 -0800)
committerJason Merrill <jason@redhat.com>
Wed, 10 May 2023 15:09:56 +0000 (11:09 -0400)
commit8d46516a61a83d24ba89086071f65a194d82ce4e
tree57f0d3898eb405b45f999ffe7e9194c58afeae66
parent688fdde2f18e3318ef7e9889fdb9b239b905dfc7
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.
gcc/cp/constexpr.cc
gcc/cp/typeck2.cc
gcc/testsuite/g++.dg/DRs/dr2543.C [new file with mode: 0644]