Can gcc accurately catch useless conditionals?

前端 未结 5 1100
萌比男神i
萌比男神i 2020-12-31 05:05

Please examine the following code:

if (foo->bar == NULL);
   foo->bar = strdup(\"Unknown\");

I spent the last part of three hours hun

5条回答
  •  情深已故
    2020-12-31 05:31

    /* foo.c */
    int main() {
       if (1) ; 
       return 0;
    }
    
    gcc -Wextra -c foo.c
    foo.c: In function ‘main’:
    foo.c:2: warning: empty body in an if-statement
    

提交回复
热议问题