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

--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <[email protected]>:

https://gcc.gnu.org/g:7b60a368fb19b33f8676482a233d389cbc47b85e

commit r17-4235-g7b60a368fb19b33f8676482a233d389cbc47b85e
Author: Joshua Berne <[email protected]>
Date:   Mon Sep 14 10:16:28 2026 -0400

    c++: fix nested instances of modifiable_tracker [PR127282]

    PR c++/127282 - [[assume]]: a nested assumption's side effects are not
    rolled back during constant evaluation

    During constant evaluation of the predicate of an [[assume]] attribute a
    pointer to a set of modifiable values is stored in the
    constexpr_global_ctx.  The class modifiable_tracker populates this value
    when evaluation of the predicate starts and clears it when it is
    complete, which results in nullptr instead of the original set when an
    [[assume]] is evaluated during the evaluation of the predicate of
    another assume.

    Fix this by storing the previous value (nullptr in non-nested cases) and
    restoring it upon destruction instead of clearing the global value.

            PR c++/127282

    gcc/cp/ChangeLog:

            * constexpr.cc (modifiable_tracker::modifiable_tracker): Save the
            current global pointer to the modifiable set.
            (modifiable_tracker::~modifiable_tracker): Restore the original
            pointer to the modifiable set instead of clearing it.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp23/attr-assume10.C: Add a case with a nested
assumption.

    Signed-off-by: Joshua Berne <[email protected]>

Reply via email to