https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117719
Bug ID: 117719 Summary: Wdangling-pointer false positive for store to heap Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: uecker at gcc dot gnu.org Target Milestone: --- I think it could warn about this: char ** h(void) { char **p = malloc(sizeof(char*)); if (!p) return NULL; char c; *p = &c; return p; } It does when moving the malloc into the caller, but this is semantically equivalent. char** f(char **p) { if (!p) return NULL; char c; *p = &c; return p; } char** g() { return f(malloc(sizeof(char*))); } https://godbolt.org/z/beYMb84qd