Menu

false positive on address of an array element?

2019-11-04
2019-11-04
  • Jyrki Kolho

    Jyrki Kolho - 2019-11-04

    To me this looks like a false positive:

    int *ptr;
    void foo(int arr[])
    {
        ptr = &arr[2];
    }
    

    cppcheck_false_positive.cpp:4:5: error: Non-local variable 'ptr' will use pointer to local variable 'arr'. [danglingLifetime]
    ptr = &arr[2];
    ^

     
  • Daniel Marjamäki

    I agree it's a false positive. thanks for reporting it, a ticket will be created asap...

     
  • Daniel Marjamäki

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.