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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to steveren from comment #0)
> Has this behaviour changed deliberately?

Yes, because the standard forbids it.

As Andrew said, the __builtin_constant_p part (and what the docs say about it)
is irrelevant because the (void *) 0x1000 expression is what gives an error.

> As I say, it is contrary to the
> Standard, but it would be disappointing to lose such a useful extension.

I think it would be better to add support to C++ for "pointer literals", I've
been talking with a few people about proposing that for the standard.

That would allow you to create constexpr pointers from literal integers, but
still disallow arbitrary reinterpret casts between them.

Closing as G++ is correct to disallow this.

Reply via email to