Can gcc accurately catch useless conditionals?

前端 未结 5 1090
萌比男神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:37

    In addition to the above, if you find yourself getting frustrated hunting for a bug using valgrind or a similar execution profiler, you should perhaps consider using a static analysis tool, such as lint. Personally, I use PC-LINT, which catches all sorts of these types of bugs.

提交回复
热议问题