34 ms·
> the address was saved somewhere No it wasn't. The address was taken, compared, then discarded, the compiler knows that it's gone out of scope and can't be us
by lmm 2y ago
> the address was saved somewhere
No it wasn't. The address was taken, compared, then discarded, the compiler knows that it's gone out of scope and can't be used again.
> It could've obviously been used to write to the variable. Is that so complicated?
It's arbitrarily complicated, in the general case, and if you can't solve it for the general case then solving it for specific special cases would only make your language semantics more confusing - if the address of q is nowhere accessible then is it safe to treat it as unused? Well, maybe, maybe not, sometimes people convert a pointer to an integer, xor it with a constant, then later xor it back. If the program converts two pointers to integers, then takes the nth root of a^n + b^n, does the compiler have to solve Fermat's last theorem to decide whether that might alias the third pointer or not?
(Or are you saying that any value whose address was taken, ever, even if that address is then discarded, must then be treated as aliasing everything else? That would create massive performance regressions)
- dataflow 2y agoNo, it wasn't discarded. I had already responded to your points here: https://news.ycombinator.com/item?id=42907000 https://news.ycombinator.com/item?id=42907000