Re: C and undefined behavior
Posted: Thu Jun 10, 2021 7:39 am
More or less, yes.Solar wrote:Thought experiment. Let's say the next generation of the architecture changes that behavior. Let's say the next x86 to appear adds different opcodes for ADD / MULT that trip on signed integer overflow, to finally get rid of all the pesky little programming mistakes.
From my POV, compiler manufacturers would be perfectly fine to make use of that new ADD/MULT. From your POV, they would not. That is what it boils down to.
The second part is totally correct. The first is not. I want determinism and simple and well-defined behavior in many more cases. In particular when I'm writing those small parts of per-architecture code inside a kernel that cannot by definition be ported. Obviously, the perspective of userspace developers is different and most (99.9%) of C and C++ code in the world is definitively not in kernel, so it's better be portable. So, it's not about laziness at all. Actually, because I'm well aware of UB and not lazy I am particularly careful and obsessed with avoiding it in my own projects. I have plenty of tests and I compile the project with both clang and gcc in a variety of configurations. All optimization levels are support from -O0 to -O3, from the very beginning. I use sanitizers like UBSAN as well. I am do my best to write 100% UB-free code. So, you simply cannot accuse me of laziness. I have a different perspective about software trade-offs than yours. That's it.Solar wrote:You want freedom to be lazy. Compiler manufacturers want freedom to produce more efficient code.
Yes, the do, sometimes. In other cases, they just don't care.Solar wrote:Well, they do the second. That's where you cross from strictly conforming to compiler-specific code.vvaltchev wrote:...unless I ask for it with an option like -fforce-alignment or something like that. Or at least, make alignment requirements default (because the ISO doc) but support an option like -fno-strict-alignment or -fallow-non-portable-features. Something like that.
Yes, simply because I went off-topic in my own thread, just to share more of my views. Otherwise, to be back on the topic, I agree with Eskil Steenberg's thesis. Obviously you don't and that's fine too. I wanted to see as many opinions as possible, instead of "fighting" with single individuals.Solar wrote:That sounds quite different from your initial statement in this thread, which was mostly about how other people misinterpreted the "true vision" of C.
I have no interest in that, at the moment, because I honestly believe I don't stand a chance. I deeply understand their perspective and their goals. It won't make much sense for them to turn back 180 degree, no matter what I say. They simply have chosen a different set of trade-offs.Solar wrote:It also puts on the table what you, and those blog writers, could do: Attend the committee meetings. Most of the compiler manufacturers are right there. You can present your reasoning, and they will consider what you have to say. They might even agree and make changes, but as you have seen in this thread, I personally would not hold my breath for it.
I can see that. You dislike people freely sharing their opinion about technology. Also, you're wrong about the public vote. People "vote" implicitly every time they use a technology. People's vote is almost all the matters. A committee has no chance at physically imposing anything on anyone. They just end up with an official piece of paper. How much that really matters, depends on willing of the people. It's simple as that.Solar wrote:I dislike this "rolling the drum to sway public opinion" approach, especially when the issue at question is decided by a committee vote, not a public vote. It basically serves no purpose, other than perhaps vent your feelings. It can also be quite damaging, even though I don't think something as well-established as C will care either way.
Our opinions do not matter to the committee, but they might to other developers. It's simple as that.Solar wrote:That is my point: Neither you nor me are on the committee. Our opinions quite plainly do not matter in this regard. Even addressing your compiler manufacturer of choice will likely only change that compiler's implementation-defined behavior if you are lucky.vvaltchev wrote:An ISO document shouldn't be treated like a gospel. At some point, it could be replaced by a different one if enough people are not OK with it.
Nice to hear that, man. I had the impression that such an opinion as mine does not even deserve to exist in your POV. While, note: I believe that my "opposite" opinion, the one shared by you and the committee is meaningful and has its good purpose to exist. I deeply respect opinions that differ with mine.Solar wrote:This is not intended to turn your opinions down.
Well.. thanks for that. Just, as you probably noticed, I'm not the most convincing guy out there, nor the most qualified in terms of expertise in computer languages etc. Mine is just a humble opinion from the POV of a kernel developer.Solar wrote:This is encouragement to take your opinion up with the committee. They are actually quite open about it. Erin Shepherd filed a paper with the committee for shortcomings of the way threads are defined in C11 she came across while working on PDCLib, and they duly discussed it.
Yeah, man. I think we exhausted all of our points. It would be great to hear other people's opinion too, if anybody else is willing to shareSolar wrote:Wait, did we just come full circle on this? Yes, I think we did.