Menu

false positive: Variable 'window_size' is assigned a value that is never used

2024-09-05
2024-09-05
  • Rob Deckers

    Rob Deckers - 2024-09-05

    This code triggers a false positive:

    const size_t window_size = 3;
    Filter<double, window_size> filter;
    
    template <typename T, std::size_t WindowSize>
        requires(WindowSize % 2 != 0)
    class Filter : public IFilter<T>
    {
        Filter()
        {
            // reserve memory in container.
            samples_.resize(WindowSize);
        }
      }
    

    Cppcheck states:

    someTest.cpp:65:18: style: Variable 'window_size' is assigned a value that is never used. [unreadVariable]
        const size_t window_size = 3;  // Odd number
                     ^
    
     
  • CHR

    CHR - 2024-09-05
     

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.