LLVM and linkers apparently can represents the distance between two symbols symbolically, but currently there is no way to get rustc to emit those instructions. The proper way to implement this would be for const-eval to have symbolic values that represent the distance between two pointers. That's possible but it's a non-trivial extension of the core const-eval machinery.
This comes up in our Windows SEH code that really would like compile-time pointer distance, and works around it with lazy initialization at runtime that is technically UB.
I don't know if that is a strong enough usecase to warrant supporting this, but it is at least worth tracking.
LLVM and linkers apparently can represents the distance between two symbols symbolically, but currently there is no way to get rustc to emit those instructions. The proper way to implement this would be for const-eval to have symbolic values that represent the distance between two pointers. That's possible but it's a non-trivial extension of the core const-eval machinery.
This comes up in our Windows SEH code that really would like compile-time pointer distance, and works around it with lazy initialization at runtime that is technically UB.
I don't know if that is a strong enough usecase to warrant supporting this, but it is at least worth tracking.