back

by josephcsible·5y ago·view on hn ↗
> Clang's internal model at HEAD appears to be assuming both outcomes happen simultaneously, which is clearly a bug

How is it clearly a bug? Undefined means undefined.

2 comments
Undefined doesn't mean contradiction in the sense that anything becomes possible. It just means it can be defined however you want, and if you choose an unsound definition then that reflects on you. Think about the history of how X3J11 was able to get people like UNIVAC and EDVAC to agree on the C standard even though they had wildly different ideas on how things like how the sign bit should work. The only way to forge a compromise is to simply say, OK, the standard won't broach that topic, keep doing what you're doing.
> in the sense that anything becomes possible

In C and C++, that's exactly what undefined behavior means. I think you're confusing it with unspecified behavior.

Because in practice, compilers are expected to do more than the language standard requires of them, and this resulting behavior is very dangerous.
The trouble dates back to the original standardization of C. An expectation of pre-standard C was left out of the standard: behavior of things like integer overflow could be determined by looking at the CPU documentation. It would have been difficult to turn that into an unambiguous requirement in the standard, and it is unlikely that people imagined what future compilers might do.

In the decades since, benchmark competition has given us the hostile mess we have today.