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

Reply via email to