https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104082
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Blocks| |104077 Status|NEW |RESOLVED --- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> --- This form of the warning implements a commonly requested feature missing from -Wreturn-local-addr (also included in -Wall): allowing the address of a local variable to escape the scope of the function. Both warnings are issued for strictly valid code. See for example pr26671, pr49974, pr54301, pr82520, pr84544, pr90905 for related requests (the initial implementation is too simplistic to fully handle all these but eventually it should). A case very similar to the one in comment #0 is documented in the manual: In the following function the store of the address of the local variable x in the escaped pointer *p also triggers the warning. void g (int **p) { int x = 7; *p = &x; // warning: storing the address of a local variable in *p } The duplication is (of course) a bug. Since the warning works as intended and documented (there's no false positive) I'm going to resolve this report as invalid. If you want to request a separate level to control this aspect please open an enhancement request (I'm open to implementing it). If you want to remove this level from -Wall, please do the same (though I don't support that request). Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104077 [Bug 104077] bogus/missing -Wdangling-pointer