this post was submitted on 18 Aug 2023
23 points (92.6% liked)
Programming
17524 readers
250 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities [email protected]
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I don't think this specific example is true, but I get the broader point. Actually, "implementation defined" is maybe a better term for this class of "undefined in the language spec but still reliable" behavior, yes.
In C, that's exactly what it is (or rather, there is some undefined-in-the-spec behavior which is machine dependent). I feel like I keep just repeating myself -- dereferencing 0 is one of those things, overflowing an int is one of those things. It can't be in the C language spec because it's machine-dependent, but it's also not "undefined" in the sense you're talking about ("clever" programming by relying on something outside the spec that's not really official or formally reliable.) The behavior you get is defined, in the manual for your OS or processor, and perfectly consistent and reliable.
I'm taking the linked author at his word that these things are termed as "undefined" in the language spec. If what you're saying is that they should be called "implementation defined" and "undefined" should mean something else, that makes 100% sense to me and I can get behind it.
The linked author seems to think that because those things exist (whatever we call them), C is flawed. I'm not sure what solution he would propose other than doing away with the whole concept of code that compiles down close to the bare metal... in which case what kernel does he want to switch to for his personal machine?