https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91548

--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Author: mpolacek
Date: Tue Oct 29 20:34:43 2019
New Revision: 277591

URL: https://gcc.gnu.org/viewcvs?rev=277591&root=gcc&view=rev
Log:
        PR c++/91548 - fix detecting modifying const objects for ARRAY_REF.

This fixes a bogus "modifying a const object" error for an array that actually
isn't declared const.  The problem was how I handled ARRAY_REFs here; we
shouldn't look at the ARRAY_REF itself, but at the array its accessing.

        * constexpr.c (cxx_eval_store_expression): Don't call
        modifying_const_object_p for ARRAY_REF.

        * g++.dg/cpp1y/constexpr-tracking-const15.C: New test.
        * g++.dg/cpp1y/constexpr-tracking-const16.C: New test.
        * g++.dg/cpp1z/constexpr-tracking-const1.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/cpp1y/constexpr-tracking-const15.C
    trunk/gcc/testsuite/g++.dg/cpp1y/constexpr-tracking-const16.C
    trunk/gcc/testsuite/g++.dg/cpp1z/constexpr-tracking-const1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/constexpr.c
    trunk/gcc/testsuite/ChangeLog

Reply via email to