5 ms·
> "undefined behavior" mainly limits portability I had the impression that some things are UB because they can't specify a single behavior that would be effici
by aw1621107 9y ago
> "undefined behavior" mainly limits portability
I had the impression that some things are UB because they can't specify a single behavior that would be efficient across all platforms C targets.
- fjsolwmv 9y agoNo that's implementation-defined. Undefined means code that is logically incorrect, but too expensive for the compiler/runtime to check and handle (reject) it. A simple example is array out of bounds access. It's too expensive to demand the compiler prevent it or guarantee to trigger some kind of signal at runtime. But if you are willing to pay the cost , you can use a language or compiler that is safer and promises to throw an exception or provides safe statically sizd arrays