diff --git a/gcc/testsuite/gcc.dg/pr105080.c b/gcc/testsuite/gcc.dg/pr105080.c new file mode 100644 index 0000000000000000000000000000000000000000..77ee7eeb396e3725a6c3b897f0fcdea88d082177 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr105080.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -Wall" } */ + +int main() +{ + char foo[3]; + int i; + + for (i = 0; i < 16; i++) + __builtin_snprintf(foo, sizeof(foo), "%d", i); /* { dg-bogus "truncated" } */ +} diff --git a/gcc/tree-ssa-strlen.cc b/gcc/tree-ssa-strlen.cc index 112f0dce874924dffdd88d2757745b506e334e72..b25563662148921e1aacf399f11a61d5d0d5f21c 100644 --- a/gcc/tree-ssa-strlen.cc +++ b/gcc/tree-ssa-strlen.cc @@ -5858,13 +5858,8 @@ 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 (); - } + loop_optimizer_init (LOOPS_NORMAL); + scev_initialize (); gcc_assert (!strlen_to_stridx); if (warn_stringop_overflow || warn_stringop_truncation) @@ -5902,11 +5897,8 @@ printf_strlen_execute (function *fun, bool warn_only) strlen_to_stridx = NULL; } - if (use_scev) - { - scev_finalize (); - loop_optimizer_finalize (); - } + scev_finalize (); + loop_optimizer_finalize (); return walker.m_cleanup_cfg ? TODO_cleanup_cfg : 0; }