Menu

Regression cppcheck 2.5 and 2.6 in MISRA rule 12.4, integer wrap around

2022-01-26
2022-01-27
  • Dani Martin

    Dani Martin - 2022-01-26

    Hi, since we have updated to Cppcheck 2.5 from 2.4, we see many false positives in misra add on for rule 12.4 (Evaluation of constant expressions should not lead to unsiged integer wrap around). It also happens with Cppcheck 2.6.

    This rule is intented for checking the limits in the operations with unsigned integers, but cppcheck is giving the warning in simple functions like:

    uint16_t simple_function(void)
    {
        uint16_t result = 0;
         retun result;
    }
    

    Does anyone have experience something similar?

     
  • Daniel Marjamäki

    ouch!

    I fail to reproduce:

    danielm@debian:~/cppcheck$ cat misra.c 
    uint16_t simple_function(void)
    {
        uint16_t result = 0;
        return result;
    }
    
    danielm@debian:~/cppcheck$ ./cppcheck --addon=misra --platform=unix64 misra.c
    Checking misra.c ...
    misra.c:1:10: style: misra violation (use --rule-texts=<file> to get proper output) [misra-c2012-8.4]
    uint16_t simple_function(void)
             ^
    

    Do you get the FP for this with that command? Or do I need to adjust something to get the FP..

     
    • Dani Martin

      Dani Martin - 2022-01-26

      Mmm...
      I will come back with more details.

      Thanks!

      El mié., 26 ene. 2022 20:59, "Daniel Marjamäki" danielmarjamaki@users.sourceforge.net escribió:

      ouch!

      I fail to reproduce:

      danielm@debian:~/cppcheck$ cat misra.c uint16_t simple_function(void){ uint16_t result = 0; return result;}
      danielm@debian:~/cppcheck$ ./cppcheck --addon=misra --platform=unix64 misra.cChecking misra.c ...misra.c:1:10: style: misra violation (use --rule-texts=<file> to get proper output) [misra-c2012-8.4]uint16_t simple_function(void) ^</file>

      Do you get the FP for this with that command? Or do I need to adjust
      something to get the FP..


      Regression cppcheck 2.5 and 2.6 in MISRA rule 12.4, integer wrap around
      https://sourceforge.net/p/cppcheck/discussion/general/thread/5bf8b9f5af/?limit=25#b311


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/cppcheck/discussion/general/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
  • Dani Martin

    Dani Martin - 2022-01-27

    ok!! I think i got it!!! Find attached an screenshot of the problem.
    I've been reviewing my setup and I found the problem: I was updating the installation of cppcheck, but I was not updating the addons folder. I have it in a separate folder, and I didn't realize it has many changes in release 2.5 and 2.6. So I just downloaded the latest version of it from github and now this strange FP have dissapeared.

    Thanks for the support anyway!! :-)

     

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.