]> git.ipfire.org Git - thirdparty/gcc.git/commit
analyzer: use correct format code for string literal indices [PR110483,PR111802]
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 27 Feb 2024 19:49:42 +0000 (14:49 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Tue, 27 Feb 2024 22:17:12 +0000 (17:17 -0500)
commit939439a90f234f9e70d30240bf5c227eebe2b43f
tree487426ac5368f3eab5ab182d22ed618f27ab384d
parent15d1dae0d4d1be88d28ad7578a60fd3e36de36d8
analyzer: use correct format code for string literal indices [PR110483,PR111802]

On e.g. gcc211 the use of "%li" with unsigned HOST_WIDE_INT led to this warning:
../../src/gcc/analyzer/access-diagram.cc: In member function ‘void ana::string_literal_spatial_item::add_column_for_byte(text_art::table&, const ana::bit_to_table_map&, text_art::style_manager&, ana::byte_offset_t, ana::byte_offset_t, int, int) const’:
../../src/gcc/analyzer/access-diagram.cc:1909:40: warning: format ‘%li’ expects argument of type ‘long int’, but argument 3 has type ‘long long unsigned int’ [-Wformat=]
          byte_idx_within_string.ulow ()));
                                        ^
and to all values being erroneously printed as "0".

Fixed thusly.

gcc/analyzer/ChangeLog:
PR analyzer/110483
PR analyzer/111802
* access-diagram.cc
(string_literal_spatial_item::add_column_for_byte): Use %wu for
printing unsigned HOST_WIDE_INT.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/access-diagram.cc