https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90949
Bug ID: 90949 Summary: [9/10 Regression] null pointer check removed Product: gcc Version: 9.1.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org CC: law at gcc dot gnu.org Target Milestone: --- From https://stackoverflow.com/questions/56655137/undefined-behaviour-or-gcc-optimization-bug int puts(const char*); void free(void*); void* malloc(unsigned long); #define NULL 0 struct Node { struct Node* child; }; void walk(struct Node* module, int cleanup) { if (module == NULL) { return; } if (!cleanup) { puts("No cleanup"); } walk(module->child, cleanup); if (cleanup) { free(module); } } int main() { struct Node* node = malloc(sizeof(struct Node)); node->child = NULL; walk(node, 1); } This crashes when compiled with -O1 -foptimize-sibling-calls -ftree-vrp since r270574 PR tree-optimization/90037 * Makefile.in (OBJS): Remove tree-ssa-phionlycprop.c * passes.def: Replace all instance of phi-only cprop with the lattice propagator. Move propagation pass from after erroneous path isolation to before erroneous path isolation. * tree-ssa-phionlycprop.c: Remove. * gcc.dg/tree-ssa/20030710-1.c: Update dump file to scan. * gcc.dg/isolate-2.c: Likewise. * gcc.dg/isolate-4.c: Likewise. * gcc.dg/pr19431.c: Accept either ordering of PHI args. * gcc.dg/pr90037.c: New test.