public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103402] New: Compile-time less/more comparison of a pointer vs nullptr
@ 2021-11-24 8:52 fchelnokov at gmail dot com
2021-11-24 9:02 ` [Bug c++/103402] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: fchelnokov at gmail dot com @ 2021-11-24 8:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103402
Bug ID: 103402
Summary: Compile-time less/more comparison of a pointer vs
nullptr
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
The following code is invalid and must be rejected:
```
int main() {
static constexpr int x = 1;
constexpr const int * p = nullptr;
static_assert( p < &x );
}
```
because less/more comparison with nullptr has unspecified value and cannot
appear in a constant expression.
Clang correctly rejects the code, demo: https://gcc.godbolt.org/z/E4ME4zh3M
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/103402] Compile-time less/more comparison of a pointer vs nullptr
2021-11-24 8:52 [Bug c++/103402] New: Compile-time less/more comparison of a pointer vs nullptr fchelnokov at gmail dot com
@ 2021-11-24 9:02 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-24 9:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103402
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-11-24
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-24 9:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24 8:52 [Bug c++/103402] New: Compile-time less/more comparison of a pointer vs nullptr fchelnokov at gmail dot com
2021-11-24 9:02 ` [Bug c++/103402] " pinskia 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).