https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123790
Bug ID: 123790
Summary: GCC doesn't initializer constexpr pointer variable of
type std::nullptr_t with another nullptr
Product: gcc
Version: 15.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jlame646 at gmail dot com
Target Milestone: ---
The following program fails with gcc but compiles with clang:
https://godbolt.org/z/M9o58MohY
```
int main()
{
using nil = decltype(nullptr) ;
constexpr nil zero = nullptr ;
constexpr nil other_zero = zero ;
}
```
GCC says:
```
Executor x86-64 gcc 15.2 (C++, Editor #1)
x86-64 gcc 15.2
Compiler options for execution
Could not execute the program
Build failed
Compiler returned: 1
Compiler stderr
<source>: In function 'int main()':
<source>:5:30: error: 'nullptr' is not a constant expression
5 | constexpr nil other_zero = zero ;
| ^~~~
```