https://gcc.gnu.org/g:43a9b8164b4bd8e7ff96f96a2a4ebd9aa6969fc1
commit r17-6363-g43a9b8164b4bd8e7ff96f96a2a4ebd9aa6969fc1 Author: Oleg Tolmatcev <[email protected]> Date: Wed Nov 11 20:44:32 2026 +0100 diagnostics: Fix -Wformat and -Wformat-diag warnings sarif-sink.cc printed a size_t with %li, which -Wformat rejects on LLP64 hosts. Use %zu. digraphs-to-dot-from-cfg.cc uses pp_printf to build dot labels, not diagnostics, so -Wformat-diag's style rules do not apply. Disable the warning for the file, as other dumping code does. gcc/ChangeLog: * diagnostics/sarif-sink.cc: Print content_length with %zu. * diagnostics/digraphs-to-dot-from-cfg.cc: Disable -Wformat-diag. Signed-off-by: Oleg Tolmatcev <[email protected]> Diff: --- gcc/diagnostics/digraphs-to-dot-from-cfg.cc | 10 ++++++++++ gcc/diagnostics/sarif-sink.cc | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/diagnostics/digraphs-to-dot-from-cfg.cc b/gcc/diagnostics/digraphs-to-dot-from-cfg.cc index 35090d71dc9e..68d1089a7e90 100644 --- a/gcc/diagnostics/digraphs-to-dot-from-cfg.cc +++ b/gcc/diagnostics/digraphs-to-dot-from-cfg.cc @@ -37,6 +37,12 @@ along with GCC; see the file COPYING3. If not see #include "selftest.h" +/* Disable -Wformat-diag; pp_printf here builds dot labels, not diagnostics. */ +#if __GNUC__ >= 10 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wformat-diag" +#endif + namespace diagnostics { namespace digraphs { namespace to_dot { @@ -321,3 +327,7 @@ make_converter_from_cfg () } // namespace to_dot } // namespace digraphs } // namespace diagnostics + +#if __GNUC__ >= 10 +# pragma GCC diagnostic pop +#endif diff --git a/gcc/diagnostics/sarif-sink.cc b/gcc/diagnostics/sarif-sink.cc index fad4e5cde8c7..7129f03010b5 100644 --- a/gcc/diagnostics/sarif-sink.cc +++ b/gcc/diagnostics/sarif-sink.cc @@ -4274,7 +4274,7 @@ private: # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wformat-diag" #endif - pp_printf (&pp_header, "Content-Length: %li\n\n", content_length); + pp_printf (&pp_header, "Content-Length: %zu\n\n", content_length); #if __GNUC__ >= 10 # pragma GCC diagnostic pop #endif
