Skip to content

COBOL engine: a group's USAGE (01 X COMP.) is not inherited by its elementary items, so sizes and offsets are wrong #4525

Closed

Description

@squid-protocol

Problem

The engine does not apply a group item's USAGE to its elementary items. In IBM Enterprise COBOL (and the 2002 standard) a USAGE clause on a group applies to every elementary item under it that has no USAGE of its own. The engine records these items as DISPLAY, so their sizes and the offsets after them are wrong. GalaxyIR.record_layout reads item.usage from the item alone.

Evidence

CardDemo app/cbl/CBSTM03A.CBL, lines 59-65:

       01  COMP-VARIABLES          COMP.
           05  CR-CNT              PIC S9(4) VALUE 0.
       ...
       01  COMP3-VARIABLES         COMP-3.
           05  WS-TOTAL-AMT        PIC S9(9)V99 VALUE 0.
item engine correct (translator)
COMP-VARIABLES (4 x S9(4) COMP) 16 bytes, 4 each 8 bytes, 2 each
WS-TOTAL-AMT (S9(9)V99 COMP-3) 11 bytes 6 bytes

The #4273 fact cross-check showed this once the det translator could read CBSTM03A (#4523: the apostrophe literal continued at line 168 had stopped the program before). The disagreements are ledgered under the cause engine-group-usage-not-inherited.

Acceptance criteria

  • An elementary item without its own USAGE takes the nearest enclosing group's USAGE, for size, class and offsets (record_data / record_layout).
  • A test with COMP, COMP-3 and POINTER groups.
  • The engine-group-usage-not-inherited entries leave tests/cobol_mainframe/fact_crosscheck_ledger.json (fact_crosscheck.py update). Golden masters are re-blessed if they move.

Found during: #4523 (det translator, continued apostrophe literals).

🤖 Generated with Claude Code

Activity

  1. added
    bug
    core-engine
    data-integrity
    legacy-modernization
    priority: high
    and removed on Oct 6, 2026
  2. added
    scope:core
    era:2
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore-enginedata-integrityera:2legacy-modernizationpriority: highscope:core

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions