https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83429

--- Comment #1 from Daniel Fruzynski <bugzi...@poradnik-webmastera.com> ---
Another test case, this time "note:" with argument range also points to
incorrect line:

[code]
#include <stdio.h>

struct S
{
    unsigned char n;
    char out[2];
};

void test(S* s) // line 9
{
    snprintf(s->out, sizeof(s->out), "%d", s->n); // line 11
}
[/code]

[out]
test.cc: In function ‘void test(S*)’:
test.cc:9:6: warning: ‘%d’ directive output may be truncated writing between 1
and 3 bytes into a region of size 2 [-Wformat-truncation=]
 void test(S* s) // line 9
      ^~~~
test.cc:9:6: note: directive argument in the range [0, 255]
test.cc:11:13: note: ‘snprintf’ output between 2 and 4 bytes into a destination
of size 2
     snprintf(s->out, sizeof(s->out), "%d", s->n); // line 11
     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[/out]

Reply via email to