]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cobol: Fix bootstrap [PR122691]
authorJakub Jelinek <jakub@redhat.com>
Sat, 15 Nov 2025 15:04:56 +0000 (16:04 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 15 Nov 2025 15:04:56 +0000 (16:04 +0100)
Andrew's recent r16-5258 change broke bootstrap on x86_64-linux with
cobol enabled, the error is
../../gcc/cobol/lexio.cc: In function ‘std::pair<std::__cxx11::list<replace_t>,
char*> parse_replace_pairs(const char*, const char*, bool)’:
../../gcc/cobol/lexio.cc:907:76: error: ‘%.*s’ directive argument is null
[-Werror=format-overflow=]
  907 |     dbgmsg( "%s:%d: %s: " HOST_SIZE_T_PRINT_UNSIGNED " pairs parsed from  '%.*s'",
      |                                                                            ^~~~
The problem is that some jump threading is happening now that didn't happen
before and a dbgmsg call is duplicated, once with 0, NULL as the last two
arguments, once with some size and pointer.

The following patch makes sure we never call it with NULL pointer, even when
the size is 0, to silence the warning.

2025-11-15  Jakub Jelinek  <jakub@redhat.com>

PR cobol/122691
* lexio.cc (parse_replace_pairs): Replace parsed.stmt.p with
parsed.stmt.size() ? parsed.stmt.p : "" in the last argument to
dbgmsg.

gcc/cobol/lexio.cc

index 52d1affee810d6fd4370d77390dfae630962a914..d7a4f1b28145f58ea82f42b03226203932ddfc13 100644 (file)
@@ -907,7 +907,8 @@ parse_replace_pairs( const char *stmt, const char *estmt, bool is_copy_stmt ) {
     dbgmsg( "%s:%d: %s: " HOST_SIZE_T_PRINT_UNSIGNED " pairs parsed from  '%.*s'",
             __func__, __LINE__,
             parsed.done() ? "done" : "not done",
-            (fmt_size_t)pairs.size(), parsed.stmt.size(), parsed.stmt.p );
+            (fmt_size_t)pairs.size(), parsed.stmt.size(),
+            parsed.stmt.size() ? parsed.stmt.p : "" );
     int i = 0;
     for( const auto& replace : pairs ) {
       dbgmsg("%s:%d:%4d: '%s' => '%s'", __func__, __LINE__,