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

            Bug ID: 119331
           Summary: cobol: unimplemented exceptions abort compilation -
                    even if requested to NOT use them
           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: ---

The COBOL standard defines a good amount of exception handling. If the user
does not enable them (via >> TURN directive or an implementor specific
extension), then the behaviour is "undefined".

The implementor specific extension from GnuCOBOL is as follows:

  -fec=<exception-name> enable code generation for <exception-name>,
                        see --list-exceptions for the possible values,
                        sets -fsource-location
  -fno-ec=<exception-name>      disable code generation for <exception-name>

the one from gcobol:

     -fcobol-exceptions exception [,exception...]
              By default, no exception condition is enabled (including fatal
ones), and by the ISO standard exception conditions are enabled only via the
CDF TURN directive.  This
              option enables one or more exception conditions by default, as
though TURN had appeared at the top of the first source code file.  This option
may also appear more than
              once on the command line.

              The value of exception is a Level 1, 2, or 3 exception condition
name, as described by ISO/IEC 1989:2023.  ‘EC-ALL’ means enable all exceptions.

              The -fno-cobol-exceptions form turns off exception, just as
though
                    >>TURN exception CHECKING OFF
              had appeared.

              Not all exception conditions are implemented.  Any that are not
produce a warning message.


Given the following command line

gcobol -fcobol-exceptions=EC-ALL -fno-cobol-exceptions=EC-DATA-INCOMPATIBLE
-fno-cobol-exceptions=EC-PROGRAM-ARG-MISMATCH
-fno-cobol-exceptions=EC-PROGRAM-ARG-OMITTED test.cob

(explanation: all exceptions are enabled with the level1, then specific level3
exceptions are disabled [because of expected runtime penalty / "legacy coding"]

there are three possible issues here:


1 - bug: in case of unknown exceptions, the compilation stops and the compiler
exits with 1
  cobol1: sorry, unimplemented: exception 'EC-DATA-INCOMPATIBLE'
  cobol1: sorry, unimplemented: exception 'EC-PROGRAM-ARG-MISMATCH'
  cobol1: sorry, unimplemented: exception 'EC-PROGRAM-ARG-OMITTED'
--> the documentation says "Any that are not produce a warning message." (I
think it should have a normal warning group and be able to suppress/increase to
an error using -Werror)

2 - design issue: exceptions that are _disabled_ - like all of the ones above
should possible not get a warning at all, similar like -Wbanana = error,
-Wno-banana = no message at all.

3 - to be considered (and possibly ignored): gcobol is free to do anything, but
given GnuCOBOL's usage, wouldn't it be reasonable to name the option identical
in gcobol as it is in cobc [the wrapper gcobc already does the translation, but
still]?

Reply via email to