Menu

False Positive: CastAddressToIntegerAtReturn

2023-11-07
2023-11-07
  • Stefan van Kessel

    On a current develop version of cppcheck I get a false positive CastAddressToIntegerAtReturn with following code:

    #include <memory>
    #include <future>
    struct Foo
    {
      std::future<int> unfinishedBlobsCount() const
      {
        return std::future<int>{};
      }
    };
    
    int unfinishedBlobsCount()
    {
      std::shared_ptr<Foo> foo = std::make_shared<Foo>();
      auto get_future = foo->unfinishedBlobsCount();
      return get_future.get();
    }
    
    ../cppcheck/build/bin/cppcheck test.cpp --enable=style --inconclusive
    Checking test.cpp ...
    test.cpp:15:3: portability: Returning an address value in a function with integer return type is not portable. [CastAddressToIntegerAtReturn]
      return get_future.get();
      ^
      [...]
    
     
  • CHR

    CHR - 2023-11-07

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

     
    👍
    1

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.