llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Checking for use of references to an automatic variable outside of its scope

Open llvmbot opened this issue 10 years ago • 2 comments

Bugzilla Link 29069
Version unspecified
OS All
Attachments This archive contains the .cpp file and the makefile described above
Reporter LLVM Bugzilla Contributor
CC @devincoughlin

Extended Description

Hello, I'd like clang's static code analyser to be able to detect use of references to an automatic variable outside of its scope. I've attached a test-case that shows a bit of code that takes pointer to an automatic variable and use that pointer outside the scope of the original automatic variable. I have also attached a make file that compiles the .cpp file so that it can be run with scan-build to run the static code analyser on the .cpp file.

llvmbot avatar Aug 20 '16 15:08 llvmbot

Aleksei Sidorin is working on a checker for this in https://reviews.llvm.org/D19979

This particular example is also something the StackAddrEscapeChecker could be extended to check because the bad pointer persists across a function return.

devincoughlin avatar Aug 21 '16 19:08 devincoughlin

assigned to @tkremenek

llvmbot avatar Aug 20 '16 15:08 llvmbot