Menu

cppcheck false divide by zero

2023-03-15
2023-03-15
  • Ladislav Vaiz

    Ladislav Vaiz - 2023-03-15
    #include <stdio.h>
    
    void main(){
        int n = 0;
    
        void inner1(){
            int a = 10 / n;
            printf("a=%d\n", a);
        }
    
        void inner2(){
            n = 2;
        }
    
        inner2();
        inner1();
    }
    

    Cppcheck says Division by zero but n is 2.

     
  • CHR

    CHR - 2023-03-15

    That seems to be a GNU extension which is not supported by cppcheck.

     

Log in to post a comment.