5 ms·
> it is surprising to see Clang developers (I presume) on the bug being so blasé about introducing undefined behavior themselves. I have suddenly lost a great
by electrograv 10y ago
> it is surprising to see Clang developers (I presume) on the bug being so blasé about introducing undefined behavior themselves.
I have suddenly lost a great deal of respect and confidence for LLVM/Clang after reading this bug thread; I value software reliability above all else, and being able to write reliable software without the compiler negating that effort. It seems I can no longer be assured this is even a priority of my compiler any more, with Clang. All the more reason to switch to Rust I suppose.
That the Clang people are trying to deflect this bug as "fine, no fix necessary" is kind of disgusting software engineering behavior. Compilers spontaneously introducing undefined behavior in another layer (to the point of causing codegen warnings from perfectly correct C code, is as clearly cut a BUG as any, independent of current API implementations outside of the ISO spec.
If you want to make undefined API calls the norm, then make a new API where the behavior you want is defined. Invoking undefined behavior of a decoupled library that users can swap out is flat out indefensible.
That they are reluctant to fix this makes me shy away from ever using Clang/LLVM, which is sad because before I had always held them with very high respect.
- chandlerc1024 10y agoUnderstand that some of the folks who don't think this is a bug own one of the libc implementations being used. So for their platform, it really is 100% correct and valid. The folks working on other platforms seem universally unhappy with that bug.
- electrograv 10y agoIf it's not 100% valid on 100% platforms and 100% of all future Libc revisions (which is impossible if it relies on undefined behavior and can link with different Libc versions), then it's not 100% correct and valid.
- chandlerc1024 10y agoOn at least one platform, all future libc revisions will abide by this requirement. And neither Clang nor LLVM are generating platform agnostic code. The code only has meaning for the specific platform being targeted.
- xorblurb 10y agoIt is not the particular situation people are upset about (well, at least me). It is the reasoning, especially in the context of "you shall not write undefined behavior according to the standard even if it should makes sens given the computer you are actually programming" that is usually sent on us regular programmer by compiler authors... :/ Yet they do exactly the same thing, and pretty much casually. And I actually don't really blame them for doing it. Everybody makes mistakes. But I blame them for the double standard, the risks, and the attitude. The problem in the first place: engineering is also about mitigating the fact that mistakes will happen, often mitigating even the mistake of others, and the modern approach in regard with undefined behavior does not help and is even ultra-hurtful for that. I don't see how stability will emerge with that kind of thought process.
- chandlerc1024 10y agoYou are tarring all compiler authors with a very broad brush here. Myself and other compiler authors I work with are much more specific in their requests. We do actually define some behavior that the standard doesn't require, and we do document this and tell our users its fine to rely on it. Unfortunately, we also have a lot of really clear experience with this stuff that lead us to two conclusions: 1) When we identify UB in code and go look at that code, for very large bodies of code what we find are overwhelmingly bugs. Bad, complete bugs. Defining the behavior wouldn't fix the bug, it was just one of the many symptoms. 2) We have real hardware differences for a lot of simple things that make them hard or impossible to give defined behavior for. As an example, shifting left by more bits than the size of the value gives different results on several different platforms. None of this means that we don't need to help programmers cope with this. We do indeed also make mistakes, and in fact it was these compiler authors that built a tool to help programmers find UB in their code: http://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html http://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
- wnoise 10y ago> We have real hardware differences for a lot of simple things that make them hard or impossible to give defined behavior for. Hard or impossible to give _performant_ defined behavior for. > As an example, shifting left by more bits than the size of the value gives different results on several different platforms. You could, for instance, always mod the shift by the word size, but possibly at a significant cost.
- archgoon 10y ago> All the more reason to switch to Rust I suppose. Rust is backed by llvm.
- lomnakkus 10y agoNot particularly sure how that's particularly relevant here. This is an issue with Clang, AFAIUI.
- archgoon 10y agoWell, electrograv was not distinguishing between the llvm project and the clang project. So it seemed reasonable to point out that rust was using llvm. > I have suddenly lost a great deal of respect and confidence for _LLVM_/Clang after reading this bug thread; However, do you believe that there is little overlap between llvm developers and clang developers?