https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86912
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2020-01-24 CC| |msebor at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> --- I'll confirm this but I'm not sure if the problem is substantively different than something as simple as the following C program where GCC doesn't fold the array reference to zero. Even declaring the array at file scope doesn't help. (I'm pretty sure there is a report of this optimization opportunity somewhere in Bugzilla.) $ cat u.c && gcc -O2 -S -Wall -fdump-tree-optimized=/dev/stdout u.c int f (int i) { const int a[] = { 0, 0, 0 }; return a[i]; // should be folded to return 0; } ;; Function f (f, funcdef_no=0, decl_uid=1930, cgraph_uid=1, symbol_order=0) f (int i) { const int a[3]; int _6; <bb 2> [local count: 1073741824]: MEM <unsigned long> [(int *)&a] = 0; a[2] = 0; _6 = a[i_5(D)]; a ={v} {CLOBBER}; return _6; }