https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94554
Marco Trevisan <mail at 3v1n0 dot net> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mail at 3v1n0 dot net --- Comment #5 from Marco Trevisan <mail at 3v1n0 dot net> --- I don't think g++ is totally wrong here, Actually, if any, it should be stronger in making the error clearer and louder, as per sé it's fine to consider that you're for real not comparing something constant and the function address may not be known at compile time, so not wrong to check. However, something that will not error but work can be something like: #include <iostream> #include <type_traits> using namespace std; int meow() { return 1; } void kitty(int i) { std::cout << "Mowed vlaue " << i << "\n"; } template <int (*F)()> void test() { using NullType = std::integral_constant<decltype(F), nullptr>; using ActualType = std::integral_constant<decltype(F), F>; if constexpr (!std::is_same_v<ActualType, NullType>) { kitty(F()); } else { kitty(222222); } } int main() { test<nullptr>(); test<meow>(); return 0; }