3 ms·
> Question to C++ pros: are there not idioms that can be used and ruthlessly enforced to avoid such problems entirely? "In theory, yes - in practice, no." You
by MaulingMonkey 6y ago
> Question to C++ pros: are there not idioms that can be used and ruthlessly enforced to avoid such problems entirely?
"In theory, yes - in practice, no."
You can use static analysis, vendor-specific annotations, runtime tools like clang's various sanitizers or valgrind, thorough code audits, use smart pointers instead of raw, have clear ownership semantics, follow MIRSA C guidelines, NASA guidelines, etc etc etc... but eventually your project will grow to the point where you'll botch an edge case, and the number of botched edge cases all your coworkers manage to add up will turn into a statistic.
Even if me and all my coworkers were all godlings incapable of making mistakes, we'd still end up debugging plenty of memory safety issues - in second/third party code, sometimes without source code, and writing bug reports / workarounds as a result.
- jillesvangurp 6y agoAlso, you can assume Google to be using all of the tools at their disposal. The stakes are high for them and they've been dealing with security issues for a long time. It helps, but it's obviously not enough. This seems to be true for most widely used C/C++ code bases; including those with decades of scrutiny. At best some projects have a good track record when it comes to dealing with these issues in a diligent way. Chromium seems to be one of those projects.