[Bug c++/93169] [10 regression] Variable incorrectly put into readonly section.
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Feb 20 00:16:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93169
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:8f9dd1b0bdd935592ba151e9d843fddf6193afbc
commit r10-6749-g8f9dd1b0bdd935592ba151e9d843fddf6193afbc
Author: Marek Polacek <polacek@redhat.com>
Date: Wed Feb 19 16:36:38 2020 -0500
c++: Fix wrong-code with non-constexpr constructor [PR93169]
In order to detect modifying constant objects in constexpr evaluation,
which is UB, in r10-2655 I added code that sets TREE_READONLY on
CONSTRUCTORs of const-qualified objects after they have been fully
constructed. But I never made sure that what we're setting the flag
on actually is a CONSTRUCTOR. Consequently, as this test case shows,
we could set TREE_READONLY on a VAR_DECL that in fact wasn't constant,
causing problems later. Fixed by setting the flag on CONSTRUCTORs
only, and only when the evaluation produced something constant.
2020-02-19 Marek Polacek <polacek@redhat.com>
PR c++/93169 - wrong-code with a non-constexpr constructor.
* constexpr.c (cxx_eval_call_expression): Only set TREE_READONLY
on constant CONSTRUCTORs.
* g++.dg/cpp0x/constexpr-93169.C: New test.
More information about the Gcc-bugs
mailing list