News for hackers. Stuff that matters.
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.
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.
Re:Clang vs. Clang by tbrownaw on Saturday August 03, 2024 @03:11PM (#41148555)
Staying under the speed limit is, in fact, pretty hard as evidenced by how often drivers fail at it.
Re:Clang vs. Clang by kevingadd on Saturday August 03, 2024 @04:30PM (#41149035)
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.)

Re:Clang vs. Clang by account42 on Monday August 05, 2024 @10:03AM (#41161461)
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.
Re:Clang vs. Clang by bluGill on Saturday August 03, 2024 @01:10PM (#41147807)
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.
Re:Clang vs. Clang by saagarjha on Saturday August 03, 2024 @02:41PM (#41148362)
Perhaps you’re not looking all that hard.
Re:Clang vs. Clang by bluGill on Saturday August 03, 2024 @07:28PM (#41150051)
Sanitizers are very good at finding ub.
Re:Clang vs. Clang by saagarjha on Sunday August 04, 2024 @06:10PM (#41156668)
Sure. That's just a function of how much UB there is, rather than them catching it all.
Re:Clang vs. Clang by pjmlp on Saturday August 03, 2024 @04:47PM (#41149143)
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.

Re:Clang vs. Clang by epcoa on Saturday August 03, 2024 @07:22PM (#41150031)
Do you know what UBSAN is? Have you used it?
Re:Clang vs. Clang by bluGill on Saturday August 03, 2024 @07:28PM (#41150056)
yes, my ci system runs it with a comprehensive test suite.