https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126105
Bug ID: 126105
Summary: gcobol ICE on a group/TYPEDEF field with an undefined
TYPE reference
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: cobol
Assignee: unassigned at gcc dot gnu.org
Reporter: peeterjoot at protonmail dot com
Target Milestone: ---
Created attachment 64932
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64932&action=edit
typedef-undefined-type-ice.cob (also inline in the bug report)
# Summary
`gcobol` aborts with an internal compiler error when a `TYPEDEF` (or group)
contains a
subordinate item whose `TYPE` clause names a typedef that is never defined. The
undefined
type gives the containing item a capacity of zero, which `symbols_update`
rejects with an
internal error instead of a normal diagnostic ("`... not found` / undefined
TYPE").
# Environment
- `gcobol (GCC) 17.0.0 20260604 (experimental)`
# Steps to reproduce
Compile the following program:
```cobol
IDENTIFICATION DIVISION.
PROGRAM-ID. CRASH2.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 CBLT-BUF IS TYPEDEF.
05 CBLTE-FE-DATE TYPE CBLTE-FE-DATE.
01 BUF TYPE CBLT-BUF.
PROCEDURE DIVISION.
GOBACK
.
```
```
gcobol -ffixed-form -c typedef-undefined-type-ice.cob -o /dev/null
```
# Actual result
```
typedef-undefined-type-ice.cob:13:1: internal compiler error: symbols_update:
data item Group #82 'BUF' capacity 0 rejected
13 | PROCEDURE DIVISION.
| ^
0x23980a3 emit_diagnostic_valist(...)
gcc/diagnostic-global-context.cc:135
0x9edeab cbl_internal_error(char const*, ...)
gcc/cobol/util.cc:3489
0x9ddebb symbols_update(unsigned long, bool)
```
# Expected result
An ordinary diagnostic that `CBLTE-FE-DATE` (the type named in the `TYPE`
clause) is not a
defined `TYPEDEF`, with a clean (non-zero) exit — no internal compiler error.
# Notes
Reduced from a larger program produced by a COBOL source-to-source transformer
that emitted
a `TYPE` reference to a typedef it did not also define. The `PROGRAM-ID`, the
field name
coinciding with the type name, and the enclosing `TYPEDEF` are not essential to
the report —
the core trigger is a `TYPE` clause naming an undefined typedef inside a
group/typedef, which
yields a zero-capacity item. (Depending on surrounding declarations gcobol may
instead abort
in `symbol_field_location` at `cobol/symbols.cc:86`; same root cause.)