4 ms·
I suspect that many undefined behaviors reflect the inability of the standard committee to come to a consensus on the nuances involved. “Punt to the implemente
by voakbasda 5mo ago
I suspect that many undefined behaviors reflect the inability of the standard committee to come to a consensus on the nuances involved. “Punt to the implementers” is a way to allow every tool vendor to select their own expected behavior in those cases.
- MarkusQ 5mo agoThen it should be "implementation defined" rather than "undefined".
- chowells 5mo agoYou seem to be operating under the assumption "undefined behavior" means "the compiler authors can decide what to do." That's not what it means. It means "any program that causes this behavior to be triggered is not a valid C program, the programmer knows this and did not submit an invalid program, and the programmer explicitly prevented this from happening elsewhere in ways automated analysis cannot detect. Proceed with compilation knowing this branch is impossible." The spelling for compiler authors getting to choose a behavior is "implementation defined", as the other comment mentions.
- tardedmeme 5mo agoIt means the C standard does not specify what the program does. Other documents may still specify what the program does. And the program definitely still does something, whether specified or not.
- chowells 5mo ago> And the program definitely still does something, whether specified or not. No. It most definitely does not mean this. Go read the series this is part of: https://blog.llvm.org/2011/05/what-every-c-programmer-should-know_14.html https://blog.llvm.org/2011/05/what-every-c-programmer-should... It is absolutely critical that people programming in C understand what real compilers in the real world do.
- tardedmeme 5mo agoAre you saying the programs in the blog post don't do things? I think they do things. The whole blog post is talking about which things they do.