https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94021
--- Comment #10 from ishikawa,chiaki <ishikawa at yk dot rim.or.jp> ---
It would be great if the problem is fixed in later versions.
I observe the error with gcc-12 on my computer yet.
*BUT* compiling with -O instead of -O2 succeeds !?
gcc-12 version.
gcc-12 (Debian 12.2.0-14) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
No error with -O !?
ishikawa@ip030:/NREF-COMM-CENTRAL/mozilla$ gcc-12 -c -O -Wall /tmp/pr94021.c
Error with -O2 as before.
ishikawa@ip030:/NREF-COMM-CENTRAL/mozilla$ gcc-12 -c -O2 -Wall /tmp/pr94021.c
/tmp/pr94021.c: In function ‘format_utc_offset’:
/tmp/pr94021.c:14:45: warning: ‘%02i’ directive output may be truncated writing
2 bytes into a region of size between 1 and 5 [-Wformat-truncation=]
14 | __builtin_snprintf (a, sizeof a, "%s%02i%02i", "+", h, m);
| ^~~~
/tmp/pr94021.c:14:38: note: directive argument in the range [0, 59]
14 | __builtin_snprintf (a, sizeof a, "%s%02i%02i", "+", h, m);
| ^~~~~~~~~~~~
/tmp/pr94021.c:14:5: note: ‘__builtin_snprintf’ output between 6 and 10 bytes
into a destination of size 8
14 | __builtin_snprintf (a, sizeof a, "%s%02i%02i", "+", h, m);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ishikawa@ip030:/NREF-COMM-CENTRAL/mozilla$