4 ms·
Yes, you can surely improve things from C. C is not a benchmark for anything other than footguns per line of code. The debug modes you mention are also availab
by fooker 2y ago
Yes, you can surely improve things from C. C is not a benchmark for anything other than footguns per line of code.
The debug modes you mention are also available in various forms in C and C++ compilers. For example ASan and UBSan in clang will do exactly what you have described. The question is, then whether these belong in the language specification or left to individual tools.
- pjmlp 2y agoAs proven multiple times throughout the computing history, individual tools are optional, and as such used less often than they actually should be. Language specification is unavoidable when using said language.
- lstodd 2y agomwahahaha. as if there is some divine "language specification" which all compilers adhere to on pain of eternal damnation. no such thing ever existed.
- pjmlp 2y agoGiven that one can write Fortran in any language, maybe you're right.
- fooker 2y agoHave you wondered why Rust or Python do not have a specification? For a bunch of languages outside the C-centric world, specifications don't exist.
- pjmlp 2y agoThe certainly have, even if it isn't a ISO one. https://docs.python.org/3/reference/index.html https://docs.python.org/3/reference/index.html https://docs.python.org/3/library/index.html https://docs.python.org/3/library/index.html https://doc.rust-lang.org/reference/index.html https://doc.rust-lang.org/reference/index.html https://doc.rust-lang.org/std/index.html https://doc.rust-lang.org/std/index.html https://ferrous-systems.com/blog/ferrocene-language-specification/ https://ferrous-systems.com/blog/ferrocene-language-specific...
- fooker 2y agoDocumentation and specification are not the same things. The intuitive distinction is that the second one is for compiler/library developers, and the former is for users. A specification can not leave any room for ambiguity or anything up to interpretation. If it does (and this happens), it is treated as a bug to be fixed.
- rcxdude 2y agoit's not just in debug modes. It should be the standard in release mode as well (IMO the distinction shouldn't exist for most projects anyway). ASan and UBSan are explicitly not designed for that.
- fooker 2y agoWell, give it a try. If you can make it work in a way that has acceptable performance characteristics, every systems language will adopt your technique overnight.
- rcxdude 2y agoI use rust, which already does this.
- fooker 2y agoSigned overflow is officially a 'bug' in rust, it traps in debug mode but silently follows LLVM/platform behavior in release mode. Huh, doesn't that sound familiar?
- steveklabnik 2y ago> silently follows LLVM/platform behavior This is not the case. It's two's compliment overflow. Also, since we're being pedantic here: it's not actually about "debug mode" or "release mode", it is tied to a flag, and compilers must have that flag on in debug mode. This gives the ability to move release mode to also produce the flag in the future, if it's decided that the overhead is worth it. We'll see if it ever is. > Huh, doesn't that sound familiar? Nope, it is completely different from undefined behavior, which gives the compiler license to do anything it wants. These are well defined semantics, the polar opposite of UB.
- samatman 2y agoRust includes a great deal of undefined behavior, unlocked with the trustme keyword. Ahem, sorry, unsafe. If only... So if we're going to be pedantic, it's safe Rust which has defined semantics for basically everything. A considerable accomplishment, to be sure.