Menu

Possible false positive for floatConversionOverflow

Martin .
2023-04-21
2023-04-24
  • Martin .

    Martin . - 2023-04-21

    As a test case I have created the following code:

    #include <stdint.h>
    
    #define TEST_CASE(f) f>70000.0 ? 5000 : (uint16_t)70000.0
    
    static uint16_t test=TEST_CASE(75000);//floatConversionOverflow
    

    The actual overflow cannot happen as the preprocesser clearly chooses 5000 for TEST_CASE(75000).

     
  • CHR

    CHR - 2023-04-24

    Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11685

     

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.