8 ms·
Trivia For the German crowd: the mentioned "felix-gcc" is fefe (known for his blog and in C circles died libc). I love the addition of `<stdckdint.h>` in moder
by the_mitsuhiko 3y ago
Trivia For the German crowd: the mentioned "felix-gcc" is fefe (known for his blog and in C circles died libc).
I love the addition of `<stdckdint.h>` in modern C. What I definitely love less is that it's quite easy to hit undefined behavior with arithmetic and I'm personally too dumb to fully avoid it. On the Rust side Miri is shaping up to be a reasonable tool to help you figure out when you do dumb stuff, maybe something like this for C would make this a more enjoyable experience. I learned that `-fsanitize=undefined` is a reasonable tool on some compilers that adds runtime checks into the binary that at least tells you what's going on in some of those cases but that requires the right kind of input making it down such a code path. Miri on the other hand is running fully at compile time.
Generally though I'm really happy to see that there are folks on the C standard that have this sort of stuff in mind.
> We deserve multiplies and subtracts and adds that don’t punch us in the face. We deserve code that actually respects what we write and what we say when we say it, so we can build the necessary safety guarantees into what I know C programmers are shipping to millions of people all over the globe daily.
Impossible to disagree
- uecker 3y agoTry -fanalyzer with new GCCs. Not finished, but already impressive.
- the_mitsuhiko 3y agoUnfortunately it does not yet manage to pick up something with overflow related undefined behavior. The example from the blog post even on trunk passes `-fanalyzer` :(
- uecker 3y agoAh, ok. But it is developing rapidly...
- meinersbur 3y agoHere is Fefe's blog entry about filing this bug: https://blog.fefe.de/?ts=bb5517a4 https://blog.fefe.de/?ts=bb5517a4 > Update: Here's the bug, and as you can see, the gcc guy who's to blame for the problem (he admits as much in the other piece of code) thinks that's fine if people get outed because he can justify an optimization in formal legal terms. Sick. Makes you wonder what you're actually doing audits for if you're then torpedoed like this. Oh, by the way: with icc (the Intel compiler) you get an assertion correctly. (translation by DeepL)