Pointer comparisons ignore provenance
Pointer comparisons ignore provenance
Posted Oct 16, 2024 17:31 UTC (Wed) by Tobu (subscriber, #24111)In reply to: C++ already gives us a tool for pointer zapping by NYKevin
Parent article: Zapping pointers out of thin air
See this comment by Ralf Jung working out the options: your -1 preferred, 1 in LLVM would have been worked around by casting the pointers to usize before doing the comparison. Final decision is that pointer comparison ignores provenance.
There are two consistent options for pointer comparisons in Rust (given that they have to be safe):
- only addresses are compared: result is true if and only if the addresses are equal
- provenance may be taken into account:
- distinct addresses always compare inequal
- equal address + equal provenance always compares equal
- equal address + inequal provenance may non-deterministically compare either way
The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:
Note: you can avoid this step in the future by logging into your LWN account.
