Y
Hacker News
new
|
ask
|
show
|
jobs
by
0c3ca83
17 days ago
Where do you think the static analyzers are baked into for C?
gcc -fanalyze ... clang -fsanitize=address ... etc
4 comments
William_BB
17 days ago
I meant static analyzers like clang-tidy and cppcheck. `-fanalyze` I suppose is a fair comparison, but `fsanitize` is not since it's not even static
link
0c3ca83
17 days ago
Yes. Both clang and GCC come with static analyzers built in. Clangs supports whole program static analysis.
link
logicchains
17 days ago
Those aren't static analyzers, they're dynamic analyzers; they only catch issues at runtime.
link
0c3ca83
17 days ago
GCC's -fanalyze, and clang's `--analyze` both run static analyzers.
link
musicale
17 days ago
macos clang (at least) also includes
clang -fbounds-safety
this is dynamic/runtime checking, but still very useful!
link
metaltyphoon
17 days ago
If this is such a good default, why make me type `-fsanatize=address? Why isn't this the default when not doing "release mode"?
link
William_BB
17 days ago
The obvious answer is that I don't want to pay for these checks at runtime and can catch most of these bugs at test time. There are definitely use cases where that's acceptable.
link
woodruffw
17 days ago
It adds nontrivial runtime cost. It’s also not a perfect mitigation (there are plenty of unsound patterns that ASan, UBSan, and TSan won’t catch).
link
0c3ca83
17 days ago
Good question. How much of a slowdown are you willing to accept on deployed systems?
link
musicale
17 days ago
Are "deployed systems" running "release mode"?
link