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

            Bug ID: 120606
           Summary: FOR loop ICE if the last expression uses an array
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: modula2
          Assignee: gaius at gcc dot gnu.org
          Reporter: gaius at gcc dot gnu.org
  Target Milestone: ---

Reproduced from the gm2 mailing list:

$ gm2 -c forarray.mod
In function ‘Init’:
cc1gm2: internal compiler error: in build2, at tree.cc:5206
0x37cc135 internal_error(char const*, ...)
        ../../gcc/diagnostic-global-context.cc:517
0x378c6b8 fancy_abort(char const*, int, char const*)
        ../../gcc/diagnostic.cc:1803
0x1cf0f1b build2(tree_code, tree_node*, tree_node*, tree_node*)
        ../../gcc/tree.cc:5206
0xec8d59 build_binary_op(unsigned long, tree_code, tree_node*, tree_node*, int)
        ../../gcc/m2/gm2-gcc/m2expr.cc:1118
0xecc1e4 m2expr_build_binary_op_check
        ../../gcc/m2/gm2-gcc/m2expr.cc:2623
0xecc2a1 m2expr_build_binary_op
        ../../gcc/m2/gm2-gcc/m2expr.cc:2639
0xecc672 m2expr_BuildMult
        ../../gcc/m2/gm2-gcc/m2expr.cc:2724
0xf1efd7 PerformLastForIterator
        m2/gm2-compiler-boot/M2GenGCC.c:2019
0xf1ecb1 CodeLastForIterator
        m2/gm2-compiler-boot/M2GenGCC.c:1926
0xf1f555 CodeStatement
        m2/gm2-compiler-boot/M2GenGCC.c:2250
0xf2f149 M2GenGCC_ConvertQuadsToTree
        m2/gm2-compiler-boot/M2GenGCC.c:9836
0xf65e68 M2Scope_ForeachScopeBlockDo2
        m2/gm2-compiler-boot/M2Scope.c:671
0xf0c285 M2Code_CodeBlock
        m2/gm2-compiler-boot/M2Code.c:510
0xef5397 Lists_ForeachItemInListDo
        m2/gm2-compiler-boot/Lists.c:391
0xf86f27 SymbolTable_ForeachProcedureDo
        m2/gm2-compiler-boot/SymbolTable.c:15431
0xf0c319 M2Code_CodeBlock
        m2/gm2-compiler-boot/M2Code.c:542
0xf0bcb1 DoCodeBlock
        m2/gm2-compiler-boot/M2Code.c:294


$ cat forarray.mod

module forarray ;


var
   array: array [0..10] of integer ;


procedure Init ;
var
   i, n: cardinal ;
begin
   array[0] := 10 ;
   n := 0 ;
   for i := 1 to array[n] do
   end
end Init ;


begin
   Init
end forarray.

Reply via email to