https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105080
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Keywords| |diagnostic
Ever confirmed|0 |1
Last reconfirmed| |2022-03-28
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. The issue is that at -O0 we do not use SCEV and thus range analysis
is limited, just using i < 16.
static unsigned int
printf_strlen_execute (function *fun, bool warn_only)
{
strlen_optimize = !warn_only;
calculate_dominance_info (CDI_DOMINATORS);
bool use_scev = optimize > 0 && flag_printf_return_value;
if (use_scev)
{
loop_optimizer_init (LOOPS_NORMAL);
scev_initialize ();
}
at -O0 we call this when warn_format_overflow > 0 || warn_format_trunc > 0 so
to improve we could maybe do || warn_only above. That would fix the bogus
diagnostic.