https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105888
Bug ID: 105888 Summary: RFE: -fanalyzer should complain when an on-stack address escapes/outlives the function Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: dmalcolm at gcc dot gnu.org Blocks: 105887 Target Milestone: --- Implemented by Clang here: https://clang.llvm.org/docs/analyzer/checkers.html#core-stackaddressescape-c Seems useful and fairly easy to implement. The analyzer already has -Wanalyzer-use-of-pointer-in-stale-stack-frame but we might as well detect stack addresses escaping. Currently region_model::pop_frame has: unbind_region_and_descendents (frame_reg,POISON_KIND_POPPED_STACK); which updates anything pointing to frame_reg or within, so that could be adapted to make a new warning. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105887 [Bug 105887] RFE: clang analyzer warnings that GCC's -fanalyzer could implement