3 ms·
The point isn’t that anyone would want to write code like this. It’s to define rules that establish what the language implementation is allowed to assume about
by pwdisswordfish4 6y ago
The point isn’t that anyone would want to write code like this. It’s to define rules that establish what the language implementation is allowed to assume about pointers when performing optimisations, and consequently, what operations code is allowed to perform without running into UB. The best way to study such rules is with edge cases like this.
It’s like a trolley problem in a way. The situation may be unlikely, but better have an answer for it ready instead of replying ‘how dare you ask such questions’.