Get Mystery Box with random crypto!

Говоря о выше написанном, разберем, о том, почему же последние | 0x1337

Говоря о выше написанном, разберем, о том, почему же последние два случая - implementation defined.

Стандарт разделяет понятия pointer to object и pointer to function. Вот, что известно о void*:

The type of a pointer to void or a pointer to an object type is called an object pointer type.

А вот что известно о reinterpret_cast преобразовании function pointer to an object pointer:

Converting a function pointer to an object pointer type or vice versa is conditionally-supported. The meaning of such a conversion is implementation-defined, except that if an implementation supports conversions in both directions, converting a prvalue of one type to the other type and back, possibly with different cv-qualification, shall yield the orignal pointer value.

Интересным здесь является появление поведения, именуемого
conditionally-supported

[defns.cond.supp] conditionally-supported - "program construct that an implementation is not required to support"

[defns.impl.defined] implementation-defined behavior - "behavior, for a well-formed program construct and correct data, that depends on the implementation and that each implementation documents"

То есть, если описанное не поддерживается, то обязательно должна быть диагностика этого случая.

P.S: До C++11 такое приведение было illegal.

#cxx #cxx11