3 ms·
I think in all these cases unsafe actually means 'leads to UB'. Converting a pointer to an integer address is problematic if you have a garbage collector due t
by ImprobableTruth 6y ago
I think in all these cases unsafe actually means 'leads to UB'.
Converting a pointer to an integer address is problematic if you have a garbage collector due to compacting. Technically it's still the dereferencing that actually causes the UB, but I don't think this is too much of a leap.
C# marking all pointers unsafe also makes sense in the same way, because "passing pointers between methods can cause undefined behavior."
- EE84M3i 6y agoI agree, I'm just pointing out that not all languages have the same safety model, even if they are similar. Converting a pointer to an integer address and never dereferencing it (e.g. to print it) does not lead to U.B., but it does leak ASLR information. Some languages consider that safe (Rust) and others do not. I think that is in an important distinction.