https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90264
Bug ID: 90264 Summary: [9/10 Regression] -Wnull-dereference false positive after r270574 Product: gcc Version: 9.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: zhroma at gcc dot gnu.org CC: jakub at gcc dot gnu.org, law at redhat dot com, rguenth at gcc dot gnu.org Blocks: 86172 Target Milestone: --- Reduced manually from lib/colors.c in util-linux 2.33.1 int like_asprintf(char **strp); int cn_sequence(char **seq) { char *out; int len; *seq = 0; /* Warning disappears when using second line (comment line A and uncomment line B). */ if ((len = like_asprintf(seq)) < 1) return -1; //line A //len = like_asprintf(seq); //line B for (out = *seq; out && *out; out++); if ((out - *seq) > len) return -2; *out = '\0'; return 0; } with "-O2 -Wnull-dereference" <source>: In function 'cn_sequence': <source>:13:8: warning: potential null pointer dereference [-Wnull-dereference] 13 | *out = '\0'; | ~~~~~^~~~~~ It seems odd to have warning with "line A" version and not to warn in "line B" example. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86172 [Bug 86172] [meta-bug] issues with -Wnull-dereference