Menu

Cyclic reverse analysis. [cppcheckError]

Bert
2022-05-27
2022-05-27
  • Bert

    Bert - 2022-05-27

    I'm using cppcheck through the platformio ide and it fails on this part of my code

    template <class... Args>
    Iterator emplace(Args&&... args) {
      Node* node = new(std::nothrow) Node(std::forward<Args>(args) ...);
      ...
    }
    

    "[high:error] Cyclic reverse analysis. [cppcheckError]"

    I actually don't know what the message means. The code is running fine though.

    PS Thanks to cppcheck I did find another (?) bug!

     
  • Daniel Marjamäki

    It is a bug in Cppcheck so nothing you can fix in your code.

    If you want you can create a short example code that reproduce the problem then we can try to fix it.

     
  • Bert

    Bert - 2022-05-27

    is it possible to suppress the error?

    I'll create an example when Im back at my PC

     

    Last edit: Bert 2022-05-27
  • Bert

    Bert - 2022-05-27
    template <class... Args>
    bool emplace(Args&&... args) {
      Node* node = new (std::nothrow) Node(std::forward<Args>(args) ...);
      if (node) {
        if (!_first) {
          _first = _last = node;
        } else {
          node->prev = _last;
          _last->next = node;
          _last = node;
        }
        return true
      }
      return false;
    }
    

    https://cppcheck.sourceforge.io/demo/ results in
    Cppcheck 2.8
    [test.cpp:3]: (error) Cyclic reverse analysis.
    Done!

     

    Last edit: Bert 2022-05-27
  • Bert

    Bert - 2022-05-27
    template <class... Args>
    bool emplace(Args&&... args) {
      Node* node = nullptr;
      node = new (std::nothrow) Node(std::forward<Args>(args) ...);
      if (node) {
        if (!_first) {
          _first = _last = node;
        } else {
          node->prev = _last;
          _last->next = node;
          _last = node;
        }
        return true
      }
      return false;
    }
    

    "[test.cpp:5]: (style) Condition 'node' is always false"

     
  • Bert

    Bert - 2022-05-27
    template <class... Args>
    bool emplace(Args&&... args) {
      Node* node = nullptr;
      node = new (std::nothrow) Node(std::forward<Args>(args) ...);
      if (node != nullptr) {
        if (!_first) {
          _first = _last = node;
        } else {
          node->prev = _last;
          _last->next = node;
          _last = node;
        }
        return true
      }
      return false;
    }
    

    This passes without errors

     
  • Paul Fultz

    Paul Fultz - 2022-05-27
     

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.