[Bug cobol/126391] ICE during RTL pass: expand: in expand_expr_real_1, at expr.cc:11729

"cvs-commit at gcc dot gnu.org via Gcc-bugs" <[email protected]> Sun, 02 Aug 2026 19:53:35 +0000
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126391

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Robert Dubner <[email protected]>:

https://gcc.gnu.org/g:c4b00249c26ea79cdca47d15b9697dac592de7de

commit r17-2888-gc4b00249c26ea79cdca47d15b9697dac592de7de
Author: Robert Dubner <[email protected]>
Date:   Sun Aug 2 15:28:50 2026 -0400

    cobol: Make pointer to stash location file-static. [PR126391]

    COBOL variable assignments can have ON SIZE ERROR clauses.  When an error
    occurs and there is such a clause, the original destination value is
    not changed.  Since the discovery of an error happens near the end, I
    chose to create a data stash for the original value; when an error is
    detected, the starting value is restored from the stash.

    The stash area is created using malloc, but never freed.  It gets
    realloced as necessary when subsequently needed.  (This avoids repeated
    malloc/free calls during execution.)

    My mistake:  I created the pointer to that area as an automatic variable
    on the stack, but assigned it to a static tree.  The mistake manifested
    here as a temporary variable with the function context as
    stored-char-length, but then later showing up with a context of prog,
    leading to the ICE, because automatic variables have to have the correct
    function context.

    The fix was to give that variable a name and give it file-static scope.

            PR cobol/126391

    gcc/cobol/ChangeLog:

            * move.cc (move_helper): static tree stash has file-static scope.