On 6/13/21 11:48 AM, José Rui Faustino de Sousa via Gcc wrote:
Hi All!
While building I started to get this error:
../../gcc-master/gcc/opts.c: In function ‘void
print_filtered_help(unsigned int, unsigned int, unsigned int, unsigned
int, gcc_options*, unsigned int)’:
../../gcc-master/gcc/opts.c:1497:26: error: ‘ ’ directive output may be
truncated writing 2 bytes into a region of size between 1 and 256
[-Werror=format-truncation=]
1497 | "%s %s", help, _(use_diagnosed_msg));
| ^~
../../gcc-master/gcc/opts.c:1496:22: note: ‘snprintf’ output 3 or more
bytes (assuming 258) into a destination of size 256
1496 | snprintf (new_help, sizeof new_help,
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
1497 | "%s %s", help, _(use_diagnosed_msg));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
My guess is that it is due to the use of the flag "-fstrict-overflow"
I am not complaining or saying that this is a bug, but the whole code
compiles fine with this flag except for this single instance...
-fstrict-overflow isn't related to the warning or to sprintf (it
controls whether signed integer overflow is considered undefined).
The warning above tells you that if help points to a string that's
255 characters long the snprintf output will be truncated. This
warning is only issued at level 2 (-Wformat-truncation=2) which
points out more instances of possible truncation than the more
conservative level 1.
Martin
Thank you very much.
Best regards,
José Rui