https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77721
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|patch |
Status|ASSIGNED |NEW
--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
The warning isn't issued at -Wformat-truncation=1 anymore but the underlying
problem still exists and can be seen at -Wformat-truncation=2 (see below). As
mentined in comment #4, there is no patch for it, and I'm not working on one.
The problem may clear up once the new VRP implementation lands.
$ gcc -O2 -S -Wall -Woverflow -Wconversion -Wpedantic -Wformat-truncation=2 -xc
t.c
t.c: In function ‘foo’:
t.c:7:21: warning: ‘%3u’ directive output may be truncated writing between 3
and 10 bytes into a region of size 4 [-Wformat-truncation=]
snprintf(p, 4, "%3u", j);
^~~
t.c:7:5: note: ‘snprintf’ output between 4 and 11 bytes into a destination of
size 4
snprintf(p, 4, "%3u", j);
^~~~~~~~~~~~~~~~~~~~~~~~
t.c: In function ‘bar’:
t.c:15:21: warning: ‘%3u’ directive output may be truncated writing between 3
and 10 bytes into a region of size 4 [-Wformat-truncation=]
snprintf(p, 4, "%3u", k);
^~~
t.c:15:20: note: using the range [0, 4294967295] for directive argument
snprintf(p, 4, "%3u", k);
^~~~~
t.c:15:5: note: ‘snprintf’ output between 4 and 11 bytes into a destination of
size 4
snprintf(p, 4, "%3u", k);
^~~~~~~~~~~~~~~~~~~~~~~~