https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91049
Bug ID: 91049 Summary: wrong location in -Wreturn-local-addr for a return throw Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- The location of the underlining in the warning for the test case below is wrong: it should point at the &i: $ cat a.C && gcc -O2 -S -Wall a.C struct X { }; void* f (int i) { X x; return i ? &i : throw x; } a.C: In function ‘void* f(int)’: a.C:8:16: warning: function may return address of local variable [-Wreturn-local-addr] 8 | throw x; | ^ a.C:3:14: note: declared here 3 | void* f (int i) | ~~~~^ Clang gets it right: a.C:7:11: warning: address of stack memory associated with parameter 'i' returned [-Wreturn-stack-address] &i : ^