An all-zero numeric representation can produce a null function pointer and violate the function-pointer
validity invariant at construction [FLS-FUNCTION-POINTER-TYPES]. A nonzero
representation does not violate that invariant merely because it came from a numeric value, but non-nullness
alone does not establish that it designates a function callable through the destination function pointer type.
In particular, the FLS defines calling a function with an ABI other than the ABI with which it was defined as
undefined behavior [FLS-CALL-EXPRESSIONS]. A numeric value cannot establish that the
address designates a function callable through the destination function pointer type. This guideline therefore
imposes a conservative subset restriction on direct numeric-to-function-pointer transmutation.
The as operator cannot directly convert a numeric value to a function pointer. Direct numeric-to-raw-pointer
as casts and numeric-to-pointer std::mem::transmute operations are prohibited by the guideline
A numeric value shall not be converted to a pointer.
|