4 ms·
You 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 d
by chandlerc1024 10y ago
You 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.