https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95175

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |SUSPENDED
                 CC|                            |jason at gcc dot gnu.org

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
Interesting, the standard doesn't actually seem to specify anything about
casting a function pointer to pointer to void, which is explicitly not an
object pointer under http://eel.is/c++draft/basic.compound#3:

[ Note: A pointer to void does not have a pointer-to-object type, however,
because void is not an object type. — end note ]

The only thing it says about casting between function and non-function pointers
is http://eel.is/c++draft/expr.reinterpret.cast#8:
Converting a function pointer to an object pointer type or vice versa is
conditionally-supported.

We currently treat the C-style cast as a reinterpret_cast, and therefore reject
it in a constant expression; GCC 9 is better about rejecting reinterpret_cast
than earlier versions that wrongly allowed them.

Curiously, clang rejects a static_cast from function pointer to void*, allows a
reinterpret_cast, rejects the reinterpret_cast in a constant expression, but
allows a C-style cast in a constant expression.  That seems inconsistent.

Suspending pending feedback from the C++ committee.

Reply via email to