This is because 0
is a null pointer constant and can be converted to unsigned long or a pointer and therefore it is ambiguous which to choose. The draft C++ standard section 4.10
Pointer conversions says (emphasis mine):
A null pointer constant is an integral constant expression (5.19) prvalue of integer type that evaluates to zero or a prvalue of type std::nullptr_t. A null pointer constant can be converted to a pointer type; the result is the null pointer value of that type and is distinguishable from every other value of object pointer or function pointer type.
While 1
is not a null pointer constant. Although 0UL
can be converted to a pointer as well it is a better match for the unsigned long constructor since no conversion is needed.