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

            Bug ID: 124081
           Summary: ICE in expand_expr_real_2 with Record with a variant
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: modula2
          Assignee: gaius at gcc dot gnu.org
          Reporter: whcox53 at gmail dot com
  Target Milestone: ---

With a relatively simple repro I get an internal compiler error:

 $ gm2 -c Variant.mod 
during RTL pass: expand
Variant.mod: In function ‘_M2_Variant_init’:
Variant.mod:10:46: internal compiler error: in expand_expr_real_2, at
expr.cc:9683
   10 |                   mset := ModuleSet{otherpart};
      |                                              ^
0x6d33a8 expand_expr_real_2(separate_ops*, rtx_def*, machine_mode,
expand_modifier)
        ../../gcc/expr.cc:9683
0x949056 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ../../gcc/expr.cc:12657
0x955684 expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier,
rtx_def**, bool)
        ../../gcc/expr.cc:9451
0x955684 store_expr(tree_node*, rtx_def*, int, bool, bool)
        ../../gcc/expr.cc:6751
0x957c86 expand_assignment(tree_node*, tree_node*, bool)
        ../../gcc/expr.cc:6472
0x957c86 expand_assignment(tree_node*, tree_node*, bool)
        ../../gcc/expr.cc:5957
0x845750 expand_gimple_stmt_1
        ../../gcc/cfgexpand.cc:3998
0x845750 expand_gimple_stmt
        ../../gcc/cfgexpand.cc:4077
0x84a6f7 expand_gimple_basic_block
        ../../gcc/cfgexpand.cc:6133
0x84c646 execute
        ../../gcc/cfgexpand.cc:6872

**********************************************
IMPLEMENTATION MODULE Variant;

VAR
    src  : SourceRef;
    mset : ModuleSet;

BEGIN
         WITH src^ DO
               IF associated THEN
                  mset := ModuleSet{otherpart};
               END;
         END;
END Variant.

************************************************
DEFINITION MODULE Variant;

TYPE
    ModuleName = ARRAY [0..511] OF CHAR;
    ModuleRange = [0..511];
    ModuleSet = SET OF ModuleRange;
    SourceKind = (m2impl, m2def, m2main, mrimpl, mrdef, mrmain);
    SourceKindSet = SET OF SourceKind;
    SourceRef = POINTER TO Source;
    Source =
        RECORD
            kind: SourceKind;
            ModuleName : ARRAY [0..511] OF CHAR;
            extern: BOOLEAN;
            depset: ModuleSet;
            CASE associated : BOOLEAN OF
            | TRUE: otherpart : ModuleRange;
            END;
        END;

CONST
      defs = SourceKindSet{m2def, mrdef};

VAR
    mtab: ARRAY ModuleRange OF SourceRef;

END Variant.

Reply via email to