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

            Bug ID: 119254
           Summary: ICE on unterminated cobol string due to use of
                    cbl_internal_error
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: cobol
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

I tried this test.cob file:

       identification division.
       program-id. hello.
       procedure division.
           display "Hello World!
           stop run.

where the string to be displayed is missing a terminator.

The output is:

[BEGIN QUOTE]
../../src/gcc/testsuite/cobol.dg/typo-2.cob:5:21: error: syntax error:
unterminated string 'Hello World!           stop run.'
    5 |            stop run.
      |                     ^

    3 |        procedure division.
      |                           ^
0x39ad16a emit_diagnostic_valist(diagnostic_t, unsigned long,
diagnostic_option_id, char const*, __va_list_tag (*) [1])
        ../../src/gcc/diagnostic-global-context.cc:97
0x10f19a2 cbl_internal_error(char const*, ...)
        ../../src/gcc/cobol/util.cc:2231
0x10acade lexer()
        ../../src/gcc/cobol/scan.l:2466
0x10aedea next_token()
        ../../src/gcc/cobol/scan_post.h:238
0x10aee08 prelex()
        ../../src/gcc/cobol/scan_post.h:249
0x10af1aa yylex()
        ../../src/gcc/cobol/scan_post.h:373
0xfff11c yyparse()
        cobol/parse.cc:15933
0x10f15c0 parse_file
        ../../src/gcc/cobol/util.cc:2144
0x10f17e2 cobol_parse_files(int, char const**)
        ../../src/gcc/cobol/util.cc:2205
0xf331bb cobol_langhook_parse_file
        ../../src/gcc/cobol/cobol1.cc:457
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
[END QUOTE]

scan.l's <<EOF>> handler has:

2462                      if( YY_START == quoted1 || YY_START == quoted2 ) {
2463                        error_msg(yylloc, "syntax error: unterminated
string '%s'",
2464                                 tmpstring);
2465                        cbl_internal_error("");
2466                      }

so it's calling cbl_internal_error, which reports DK_ICE.

ICE is intended for handling a crash; it shouldn't be used for
recovering/aborting on syntax errors in the user's code.

Reply via email to