On 2/19/20 11:12 PM, Marek Polacek wrote:
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.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

OK.

2020-02-19  Marek Polacek  <pola...@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.


Reply via email to