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

            Bug ID: 119772
           Summary: FE: COBOL2025/2026 (original GnuCOBOL extension)
                    LENGTH OF usage-specification missing
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: cobol
          Assignee: unassigned at gcc dot gnu.org
          Reporter: simonsobisch at gnu dot org
  Target Milestone: ---

Before the next COBOL standard (or: before GnuCOBOL added this extension back
in the old OpenCOBOL days) the way to get the length of a usage-specification
was to first define an unused data item with that specification.

       01 D-BINARY-CHAR        USAGE BINARY-CHAR.
       01 Len-BINARY-CHAR      CONSTANT AS LENGTH OF D-BINARY-CHAR.

With the new standard/gnucobol the following may be coded instead

       01 Len-BINARY-CHAR      CONSTANT AS LENGTH OF BINARY-CHAR.

which currently raises

> error: syntax error, unexpected COMPUTATIONAL

This should be at least supported for -dialect gnu (GnuCOBOL) as it used there
as a replacement of the sizeof operator in C. As the upcoming COBOL standard
added this (it is part of the working draft, which sadly is only available via
national standard body or when working in the COBOL development group) and does
not conflict with anything else you possibly want to support that independent
from the dialect.

I _think_ that should be an easy addition.

Reply via email to