[Bug cobol/123890] SORT: multi-dimensional table leads to internal compile error

simonsobisch at gnu dot org via Gcc-bugs <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123890

Simon Sobisch <simonsobisch at gnu dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simonsobisch at gnu dot org

--- Comment #2 from Simon Sobisch <simonsobisch at gnu dot org> ---
The ice on the original example does not happen any more ("fixed" by another
bug in gcc 16), instead there is a "clean" compile error now:

<source>:11:8: error: TABLE-05: no key defined
   11 |        SORT TABLE-05(1) ON DESCENDING KEY-VAR
      |        ^~~~~~
cobol1: error: failed compiling <source> 

... but that's wrong per ISO, which supports this code and notes that the key
_may_ be left away from the sort statement:

> The KEY phrase may be omitted only if the description of the table referenced by data-name-2 contains a KEY phrase.

---> it does not need to contain a key phrase.


Using an example with the key phrase and sorting an inner element, there are
parser errors (since gcc 15):


         SORT TABLE-05 (SUB-03) ON DESCENDING KEY-VAR

<source>:31:24: error: syntax error, unexpected '('
   31 |          SORT TABLE-05 (SUB-03) ON DESCENDING KEY-VAR
      |                        ^~
cobol1: error: failed compiling <source>


full example (and comparison to GnuCOBOL at https://godbolt.org/z/fvvYaerfa)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.