https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86572
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=86434 --- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> --- See also bug 86434 which discusses another couple of problems with this transformation. The solution in this case isn't necessarily to defer the folding until later but do it in a way that avoids these excessive results for undefined input. For example, returning zero would be safer and in line with what GCC does in other cases, such as in some instances of out-of-bounds array accesses: $ cat c.c && gcc -O2 -Wall -Wextra -fdump-tree-optimized=/dev/stdout c.c const char a[4] = { 1, 2, 3 }; int f (void) { return a[8]; // missing -Warray-bounds, folded to zero } ;; Function f (f, funcdef_no=0, decl_uid=1899, cgraph_uid=1, symbol_order=1) f () { <bb 2> [local count: 1073741825]: return 0; }