Menu

false positive

2022-06-23
2022-07-05
  • Harshit Agarwal

    Harshit Agarwal - 2022-06-23

    my code:
    {
    typedef unsigned uint32_t;
    uint32_t shift ;
    shift = shift >> 8u;
    }

    cppcheck output :

    shiftTooManyBits
    Shifting 4-bit value by 8 bits is undefined behaviour

     
  • Harshit Agarwal

    Harshit Agarwal - 2022-06-23

    i have enabled three std checks
    --addon=misra --std=c11 --std=c++11

    Specially below two are detected false if I compare cppcheck with the LDRA output .
    “misra-c2012-R.12.2” (--addon=misra)
    “shiftTooManyBits” (--std=c11 --std=c++11).

     
  • Daniel Marjamäki

    I fail to reproduce

    $ cat 1.c
    typedef unsigned uint32_t;
    uint32_t shift ;
    shift = shift >> 8u;
    
    $ ./cppcheck --enable=style --std=c11 --std=c++11 --addon=misra 1.c
    Checking 1.c ...
    1.c:2:1: style: misra violation (use --rule-texts=<file> to get proper output) [misra-c2012-8.1]
    uint32_t shift ;
    ^
    
     

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.