public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/80886] __builtin_constant_p magic has broken at some point
[not found] <bug-80886-4@http.gcc.gnu.org/bugzilla/>
@ 2022-01-07 3:53 ` pinskia at gcc dot gnu.org
2022-01-07 11:34 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-07 3:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80886
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This has nothing to do with __builtin_constant_p really.
Just GCC started to rejecting:
constexpr void *phardware {((void *) 0x1000)};
Starting in GCC 7; it was accepted before.
What is interesting is the __builtin_constant_p makes clang accept it but that
is a clang bug.
>This use appears to be documented
I don't think it was ever documented to be accepted this way but I could be
wrong.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/80886] __builtin_constant_p magic has broken at some point
[not found] <bug-80886-4@http.gcc.gnu.org/bugzilla/>
2022-01-07 3:53 ` [Bug c++/80886] __builtin_constant_p magic has broken at some point pinskia at gcc dot gnu.org
@ 2022-01-07 11:34 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2022-01-07 11:34 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-07 11:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-80886-4@http.gcc.gnu.org/bugzilla/>
2022-01-07 3:53 ` [Bug c++/80886] __builtin_constant_p magic has broken at some point pinskia at gcc dot gnu.org
2022-01-07 11:34 ` redi at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).