Bug 99701 - std::nullptr_t can be compared with relational ops
Summary: std::nullptr_t can be compared with relational ops
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Marek Polacek
Keywords: accepts-invalid
Depends on:
Reported: 2021-03-21 20:38 UTC by Christopher Di Bella
Modified: 2021-07-27 15:40 UTC (History)
2 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2021-03-21 00:00:00

Temp file for provided source (129 bytes, text/plain)
2021-03-21 20:38 UTC, Christopher Di Bella

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Di Bella 2021-03-21 20:38:23 UTC
Created attachment 50443 [details]
Temp file for provided source

The following program is valid in all versions of GCC from 4.7.1 through trunk[1]. Relational operations on std::nullptr_t don't really make sense since there's only one value.

auto lt = nullptr < nullptr;
auto gt = nullptr > nullptr;
auto le = nullptr <= nullptr;
auto ge = nullptr >= nullptr;

This was apparently addressed by DR583/N3478 (thanks to Richard Smith for providing these).

[1]: https://godbolt.org/z/h11183

# Versions

* All GCC releases at least as far back as 4.7.1 (where I stopped looking).

# System type

* Debian (checked GCC 10.2.1)
* Compiler Explorer (checked all other reported versions).

# Options given to GCC

`g++ -save-temps nullptr-relop.cpp -c -std=c++20`
Comment 1 Marek Polacek 2021-03-22 13:15:57 UTC
Mine (for GCC 12).
Comment 2 Marek Polacek 2021-07-27 15:40:51 UTC
Fixed in GCC 12.