ARTICLE AD BOX
Yeah GCC/Clang are right — since C++17 you can totally use a constexpr nullptr_t variable as a nontype template arg when the parameter is decltype(nullptr) (or auto in C++17+).
MSVC is just behind on this one (still rejects it in 2025/2026 main branch), EDG is being extra strict / old-school about constant expressions here.
Quick thing that usually works everywhere now:
template<auto P> inline constexpr int v = 0;
constexpr auto nil = nullptr;
static_assert(v<nil> == 0); // accepted by gcc/clang/msvc 2025+
So your original example with auto nil = nullptr; is actually standard-conforming (as long as you use decltype(nullptr) or auto for the template param).
MSVC bug → give them a few more months/years ¯\_(ツ)_/¯
that's it
Explore related questions
See similar questions with these tags.
