Menu

false positive

2016-12-16
2021-01-27
  • Bill Torpey

    Bill Torpey - 2016-12-16

    Hi all:

    I'm trying to enter this at trac.cppcheck.net, but I'm starting to think I'll never get the verification email :-(

    Anyway, what looks like a false positive:

    [nsb/api/include/dateTime.h:169]: (style, inconclusive) Technically the member function 'ServiceBus::DateTime::operator++' can be const.

    DateTime operator++(int) { <----- 'line No 169'
    DateTime d = this;
    ++(
    this);
    return d;
    }

    Thanks again for a terrific tool!

     
  • CHR

    CHR - 2021-01-27

    Although the code sample is incomplete, this is basically https://trac.cppcheck.net/ticket/10077
    The warning appears for

    struct DateTime {
    int i{};
    DateTime operator++() {++i;}
    DateTime operator++(int) {
    DateTime d = *this;
    ++(*this);
    return d;
    }
    };
    
     

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.