2 ms·
> As a layman undefined appears to mean a specific thing here. "undefined by the specification because it does whatever the hardware does" in this context it sh
by inetknght 3y ago
> As a layman undefined appears to mean a specific thing here. "undefined by the specification because it does whatever the hardware does" in this context it should never mean "can not happen because it is undefined by the specification".
Actually, undefined means "undefined by the specification". It doesn't matter what the hardware does. The specification allows the hardware to do whatever it wants. It's perfectly valid to wipe your hard drive if you trigger undefined behavior.
- deleted 3y ago[deleted]
- dunham 3y agoI also wouldn't expect "undefined" to be consistent within a single compiler implementation. The optimizer is free to make different instances behave differently.
- Someone 3y agoA single compiler can even seem inconsistent. A conforming compiler is allowed to completely remove undefined behavior like this: if((n << 64) == 0) { println("Hi!\n"); } if((n << 64) != 0) { println("Hi!\n"); } If it were implementation-defined, it would have to compile it to the equivalent of println("Hi!\n");
- deleted 3y ago[deleted]