Clang static analysis results for dmd

bearophile bearophileHUGS at lycos.com
Thu Jul 28 17:19:14 PDT 2011


Walter:

> I've been slowly going through the reports, and so far all of them have been 
> false positives.

Somewhere I have read that the errors found by Clang are so often true bugs they have a tool that submits bug reports automatically. I now presume they were wrong.

But keep in mind that Clang static analysis is a *very young* sub-tool. It's something like a year or so old. There are commercial C/C++ lints that are probably about or more than 20 years old that are probably less buggy and more precise than the Clang compiler, and they find far more kinds of problems in the code. It often finds issues in my code (usually stylistic issues, not true bugs, but I usually agree with its advice and change my code).


> There are other false positives for things like assigning an uninitialized value 
> to a field in a data structure that will never be used in the cases where it is 
> uninitialized. I could add a conditional, but that's slower than just assigning 
> it anyway. Trying to figure these things out with static analysis is impossible 
> - it would be solving the halting problem - hence you're stuck with false positives.

Probably there are ways for a programmer+language to tell such simple semantics to a compiler, but C language is not good enough for this.

Thank you for your answers. It's always interesting when "theory" (of practical-purposed software tools) meets the road of the experiment reality. I hope Clang has not wasted too much of your time.

Bye,
bearophile


More information about the Digitalmars-d mailing list