Menu ▾ ▴

False negative: local address escape through a pointer temporary

Rodri
2026-09-29
2026-09-30
  • Rodri

    Rodri - 2026-09-29

    Hi, I found a false negative regarding the rule autoVariables.

    Cppcheck misses an escaping local address when it passes through a pointer temporary.

    void f(int **out) {
      int local = 1;
      int *temporary = &local;
      *out = temporary;
    }
    

    Actual result

    Cppcheck does not report autoVariables. Replacing the last two statements with *out = &local; produces the warning.

    Expected result

    Cppcheck should report that the address of the local variable is assigned through the output parameter in both forms.

    Verification

    The issue was reproduced with:

    cppcheck --output-format=xmlv2 --enable=all local_address.cpp
    

    Version: 2.21.0

     
  • CHR

    CHR - 2026-09-30

    Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15073

     

Log in to post a comment.