public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-9199] analyzer: use correct format code for string literal indices [PR110483, PR111802]
@ 2024-02-27 22:19 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2024-02-27 22:19 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:939439a90f234f9e70d30240bf5c227eebe2b43f

commit r14-9199-g939439a90f234f9e70d30240bf5c227eebe2b43f
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Tue Feb 27 14:49:42 2024 -0500

    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>

Diff:
---
 gcc/analyzer/access-diagram.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/analyzer/access-diagram.cc b/gcc/analyzer/access-diagram.cc
index 9555ee82393..24d203f9325 100644
--- a/gcc/analyzer/access-diagram.cc
+++ b/gcc/analyzer/access-diagram.cc
@@ -1905,7 +1905,7 @@ private:
 	const table::rect_t idx_table_rect
 	  = btm.get_table_rect (&m_string_reg, bytes, byte_idx_table_y, 1);
 	t.set_cell_span (idx_table_rect,
-			 fmt_styled_string (sm, "[%li]",
+			 fmt_styled_string (sm, "[%wu]",
 					    byte_idx_within_string.ulow ()));
       }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-27 22:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-27 22:19 [gcc r14-9199] analyzer: use correct format code for string literal indices [PR110483, PR111802] David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).