[Bug c++/95175] [9/10/11 Regression] constexpr and alias template
jason at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jun 3 19:39:31 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95175
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|SUSPENDED |RESOLVED
Resolution|--- |INVALID
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Jason Merrill from comment #2)
> 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 ]
I was misreading this passage; pointer to void is an object pointer type even
though it is not a pointer-to-object type.
"The type of a pointer to cv void or a pointer to an object type is called an
object pointer type."
> 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.
So this passage covers this case.
> 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.
And this is correct.
> 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.
Richard Smith from the clang team agrees that this is a clang bug.
So, your testcase is ill-formed.
More information about the Gcc-bugs
mailing list