Menu

zerodiv

2020-05-26
2020-05-26
  • houzhengtao

    houzhengtao - 2020-05-26
    #include <cstdint>
    
    
    enum testEnum : uint32_t {
        a
    };
    
    
    int main(){
        1 / sizeof(testEnum); //This statement reports an error;
        //1 / sizeof(uint32_t); //This statement is OK;
    
        return 0;
    }
    

    error report:
    Checking sizeof_enum_uint32_t.cpp ...
    sizeof_enum_uint32_t.cpp:10:7: error: Division by zero. [zerodiv]
    1 / sizeof(testEnum); //This statement reports an error;
       ^

    I think it is a bug. Anyone meets this problem ?

     

    Last edit: houzhengtao 2020-05-26
  • houzhengtao

    houzhengtao - 2020-05-26

    sizeof_enum_uint32_t.cpp

     

    Last edit: houzhengtao 2020-05-26
  • Daniel Marjamäki

    Thanks! I created this ticket: https://trac.cppcheck.net/ticket/9741

     

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.