3 ms·
Not really. Pointers from different allocations are guaranteed to never alias. If they do, it is UB.
by 1718627440 2y ago
Not really. Pointers from different allocations are guaranteed to never alias. If they do, it is UB.
- AnimalMuppet 2y agoRight, but the compiler in general has no way to know that pointers are from different allocations - especially several function calls away from the allocations, with some pointer arithmetic in between.
- 1718627440 2y agoYes, that is why restrict was introduced.
- bee_rider 2y agoIn general, the information as to whether or not the pointers will alias might not even be known, right? Like we could be compiling a library that will take in some pointers from the user.