constexpr renaming with type nullptr_t : nullptr is not a constant expression

4 days ago 7
ARTICLE AD BOX

I've nailed down my problem to the following example :

int main() { using nil = decltype(nullptr) ; constexpr nil zero = nullptr ; constexpr nil other_zero = zero ; }

Compiling this code with g++ (GCC) 15.2.1 20260103 yields

test.cpp: In function ‘int main()’: test.cpp:5:30: error: ‘nullptr’ is not a constant expression 5 | constexpr nil other_zero = zero ; | ^~~~

No such error with clang++. Using void* or auto instead of nil removes the error. Is there something I messed up ?

Read Entire Article