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

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

https://gcc.gnu.org/g:31b012f7606ce7de82442e723ee62c05842c0f76

commit r16-8605-g31b012f7606ce7de82442e723ee62c05842c0f76
Author: Gaius Mulley <[email protected]>
Date:   Tue Apr 14 13:49:07 2026 +0100

    PR modula2/105408 ICE in output_constructor_regular_field, at
varasm.cc:5515

    This patch fixes an ICE reported as PR modula2/105408.  It manifests on
    big endian system when an ISO WORD is assigned a constant.  An ISO WORD
    is an array of LOC and the constant array elements are created in reverse
    indice order (for big endian).  This fix corrects the indice order and
    also fixes calls to builtin_memcpy when used during assignment.  It uses
    memcpy during assignment for arrays of constants.
    Bootstrapped on sparc64, aarch64, x86_64 and POWER10.

    gcc/m2/ChangeLog:

            PR modula2/105408
            * Make-lang.in (GM2-COMP-BOOT-MODS): Remove duplicate NameKey.mod.
            * gm2-compiler/M2GenGCC.mod (import): Remove BuildAssignmentTree.
            Add CopyMemcpy.
            (IsSystemTypeBecomes): New procedure function.
            (CodeAssignment): Rewrite using CopyMemcpy and IsSystemTypeBecomes.
            * gm2-gcc/m2convert.cc (const_to_ISO_aggregate_type): Reverse
            array elements if BYTES_BIG_ENDIAN.
            * gm2-gcc/m2pp.cc (ps): New function.
            * gm2-gcc/m2pp.h (pf): Added comment.
            (pe): Ditto.
            (pt): Ditto.
            (ptl): Ditto.
            (pv): Ditto.
            (ptcl): Ditto.
            * gm2-gcc/m2statement.cc (copy_memcpy): Replace with ...
            (m2statement_CopyMemcpy): ... this.
            (CopyByField_Lower): Call m2statement_CopyMemcpy instead of
copy_memcpy.
            (m2statement_BuildAssignmentTree): Tidied up comment.
            Add test for ARRAY_TYPE CONSTRUCTOR expr and use
            m2statement_CopyMemcpy.
            Return type changed to void.
            * gm2-gcc/m2statement.def (BuildAssignmentTree): Rewrite
declaration.
            (CopyMemcpy): New procedure declaration.
            * gm2-gcc/m2statement.h (m2statement_BuildAssignmentTree): Replace
            return type with void.
            (m2statement_CopyMemcpy): New function declaration.
            * gm2-gcc/m2type.cc (m2type_ReverseArrayConstructorElements): New
            function.
            * gm2-gcc/m2type.def (ReverseArrayConstructorElements): New
            procedure function declaration.
            * gm2-gcc/m2type.h (m2type_ReverseArrayConstructorElements): New
            function declaration.

    gcc/testsuite/ChangeLog:

            PR modula2/105408
            * gm2/iso/run/pass/testgeneric.mod: Corrected printf arguments.
            * gm2/iso/run/pass/printsize.mod: New test.
            * gm2/iso/run/pass/testgeneric2.mod: New test.
            * gm2/iso/run/pass/testgeneric3.mod: New test.
            * gm2/iso/run/pass/testgeneric4.mod: New test.
            * gm2/iso/run/pass/testgeneric5.mod: New test.

    Signed-off-by: Gaius Mulley <[email protected]>

Reply via email to