Menu

possible future enhancement - detect shift overflow ?

dcb
2014-09-11
2014-09-12
  • dcb

    dcb - 2014-09-11

    $ more sep11b.cc

    void g( int n);

    void f( int n)
    {
    if (n & (0xff << 28))
    g( n);
    }
    $ ~/cppcheck/trunk/cppcheck --enable=all sep11b.cc
    Checking sep11b.cc...
    $ clang++ -c -O2 -Wall sep11b.cc
    sep11b.cc:6:16: warning: signed shift result (0xFF0000000) requires 37 bits to
    represent, but 'int' only has 32 bits [-Wshift-overflow]
    if (n & (0xff << 28))
    ~~~~ ^ ~~
    1 warning generated.
    $

     
  • Daniel Marjamäki

    it doesn't sound bad. you can report it in our issue tracker so we don't forget this.

     

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.