Consider: void foo (int *p, int q) { if (p == 0) { if (q == 0) { int *r = &p[q]; if (r != 0) link_error (); } } }
Note that the innermost "if" condition should be folded to false, but VRP folds that to true. Under "if (q == 0)", both p and q are known to be zero, but VRP thinks that regardless of their values, p + q is always nonnull. -- Summary: VRP thinks <ptr type> + <ptr type> is always nonnull. Product: gcc Version: unknown Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P2 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: kazu at cs dot umass dot edu CC: dnovillo at redhat dot com,gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22117