https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100503
Bug ID: 100503 Summary: A possible divide by zero problem in function do_rpo_vn Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: yguoaz at cse dot ust.hk Target Milestone: --- In gcc/tree-ssa-sccvn.c, the function do_rpo_vn has the following code (link to the code location: https://github.com/gcc-mirror/gcc/blob/releases/gcc-11/gcc/tree-ssa-sccvn.c#L7815-#L7842) static unsigned do_rpo_vn (function *fn, edge entry, bitmap exit_bbs, bool iterate, bool eliminate) { ... int nex = 0; ... for (int i = 0; i < n; ++i) { basic_block bb = BASIC_BLOCK_FOR_FN (fn, rpo[i]); if (bb->flags & BB_EXECUTABLE) nex++; } ... statistics_histogram_event (cfun, "RPO iterations", 10*nblk / nex); } In the loop, the code counts the number of basic blocks with BB_EXECUTABLE flag in variable nex and use it as divisor after exiting the loop. If no basic block has such flag, then we will have a divide by zero problem. Is this possible ? Or we must have at least one bb with the flag BB_EXECUTABLE ?