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

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

https://gcc.gnu.org/g:81582ca6cb692098c1bda7995aec46c6cbfbfcb3

commit r15-7968-g81582ca6cb692098c1bda7995aec46c6cbfbfcb3
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.

Reply via email to