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

--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Iain Buclaw
<ibuc...@gcc.gnu.org>:

https://gcc.gnu.org/g:2b37c9973967230b01dc5e38770fb3ec84610555

commit r13-9423-g2b37c9973967230b01dc5e38770fb3ec84610555
Author: Iain Buclaw <ibuc...@gdcproject.org>
Date:   Tue Mar 11 17:56:18 2025 +0100

    d: Fix regression returning from function with invariants [PR119139]

    An optimization was added in GDC-12 which sets the TREE_READONLY flag on
    all local variables with the storage class `const' assigned.  For some
    reason, const is also being added by the front-end to `__result'
    variables in non-virtual functions, which ends up getting wrong code by
    the gimplify pass promoting the local to static storage.

    A bug has been raised upstream, as this looks like an error in the AST.
    For now, turn off setting TREE_READONLY on all result variables.

            PR d/119139

    gcc/d/ChangeLog:

            * decl.cc (get_symbol_decl): Don't set TREE_READONLY for __result
            declarations.

    gcc/testsuite/ChangeLog:

            * gdc.dg/pr119139.d: New test.

    (cherry picked from commit 81582ca6cb692098c1bda7995aec46c6cbfbfcb3)

Reply via email to