Remix.run Logo
▲ William_BB a day ago

IMO you cannot fairly compare static analyzers/sanitizers with features baked into the language/compiler.

Though I've noticed the same trend when reading a famous Rust primer for C++ developers. Like there are obviously so many good and valid arguments when comparing the two languages that would've gotten the point across. Yet the authors felt the need to push it one step further, where the comparison no longer seems fair. Like comparing Rust with C++17 when C++20 provides the same exact feature that Rust claims to provide.

▲dnautics a day ago | parent | next [-]

I'm very certain you can statically analyze zig's IR for safety without language change. And zig makes it easier to get consistency than C because you are steered away from the mishmash of malloc/jemalloc/pick-your-allocator-function. (The analyzer can say "all bets are off if you don't use the allocator interface") same with the new stdlib io interface for async-shaped analysis on aliasing analysis

github.com/ityonemo/clr

▲0c3ca83 a day ago | parent | prev [-]

Where do you think the static analyzers are baked into for C?

    gcc -fanalyze ...
    clang -fsanitize=address ...
    etc
▲William_BB a day ago | parent | next [-]

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

▲0c3ca83 a day ago | parent [-]

Yes. Both clang and GCC come with static analyzers built in. Clangs supports whole program static analysis.

▲musicale 16 hours ago | parent | prev | next [-]

macos clang (at least) also includes

    clang -fbounds-safety
this is dynamic/runtime checking, but still very useful!
▲logicchains a day ago | parent | prev | next [-]

Those aren't static analyzers, they're dynamic analyzers; they only catch issues at runtime.

▲0c3ca83 a day ago | parent [-]

GCC's -fanalyze, and clang's `--analyze` both run static analyzers.

▲metaltyphoon a day ago | parent | prev [-]

If this is such a good default, why make me type `-fsanatize=address? Why isn't this the default when not doing "release mode"?

▲William_BB a day ago | parent | next [-]

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.

▲woodruffw a day ago | parent | prev | next [-]

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).

▲0c3ca83 a day ago | parent | prev [-]

Good question. How much of a slowdown are you willing to accept on deployed systems?

▲musicale 16 hours ago | parent [-]

Are "deployed systems" running "release mode"?