[llvm-bugs] [Bug 42262] New: feature request: detect use of out of scope variables

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 12 15:12:15 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42262

            Bug ID: 42262
           Summary: feature request: detect use of out of scope variables
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: dcb314 at hotmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

For this C code, please warn:

extern void g( char *);

void f( int n, char * p1)
{
        char * p2;

        p2 = p1;

        if (n >= 0)
        {
                char buf[ 10];

                p2 = buf;
        }
        g( p2);
}

For example. cppcheck says this:

[nov16a.cc:14] -> [nov16a.cc:12] -> [nov16a.cc:16]: (error) Using pointer to
local variable 'buf' that is out of scope.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190612/6dbdec5a/attachment.html>


More information about the llvm-bugs mailing list