Re:Clang vs. Clang
by bluGill on Saturday August 03, 2024 @12:50PM
(#41147675)
If you have ub then you have a bug and there is some system that will show it. It isn't hard to write code without ub.
[ Parent
| on HN ]
Re:Clang vs. Clang
by bigstrat2003 on Saturday August 03, 2024 @12:55PM
(#41147702)
It is, in fact, pretty hard as evidenced by how often programmers fail at it. The macho attitude of "it's not hard, just write good code" is divorced from observable reality.
Staying under the speed limit is, in fact, pretty hard as evidenced by how often drivers fail at it.
It's more complex than that for the example of car speed limits. Depending on where you live, the law also says that driving too slow is illegal because it creates an unsafe environment by forcing other drivers on i.e. the freeway to pass you.
But yeah, seeing how virtually everyone on every road is constantly speeding, that doesn't give me a lot of faith in my fellow programmers' ability to avoid UB...
Re:Clang vs. Clang
by deathanatos on Saturday August 03, 2024 @09:36PM
(#41150553)
Some jurisdictions also set the speed limit at, e.g., the 85th percentile of drivers' speed (https://en.wikipedia.org/wiki/Speed_limit#Method) so some drivers are always going to be speeding.
(I'm one of those speeders, too; I drive with a mentality of safety > following the strict letter of the law; I'll prefer speed of traffic if that's safer than strict adherence to the limit. That said, I know not all of my peers have the same priorities on the road, too.)
And to be specific, some kinds of UB are painfully easy to avoid. A good example of that is strict aliasing. Simply don't do any type punning. Yet people still complain about it being the compiler's fault when their wanton casting leads to problems.
People write buffer overflows because and memory leaks they are not coreful. The rest of ub are things I have never seen despite running sanitizers and a large codebase.
Perhaps you’re not looking all that hard.
Sanitizers are very good at finding ub.
Sure. That's just a function of how much UB there is, rather than them catching it all.
Only if developers act as grown ups and use all static analysers they can get hold of, instead of acting as they know better.
The tone of my answer is a reflection of what most surveys state, related to the actual use of such tooling.
Do you know what UBSAN is? Have you used it?