------- Comment #9 from mdorey at bluearc dot com 2009-04-28 20:00 ------- (In reply to comment #1) > Because a null pointer constant is an integral constant expression, thus the > warning is wrong.
Are all integral constant expressions necessarily implicitly convertible to all integer types? I'd have thought so but, having read the references I cite below, now I don't. > See PRs 5310 and 24745. Both of those seem reasonable. They're addressed by http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#654. The cited paper is at http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2656.htm. Implicit conversion to bool is clearly mandated (PR 24745). Explicit conversion to int is clearly mandated (PR 5310). The situation regarding implicit conversion to non-bool integral types (this PR) is slightly less clear, but, quoting Jason Merrill in the accepted defect 654 [ int n3 = expr ? nullptr : nullptr; // error, nullptr_t cant be converted to int Basically, I would like nullptr_t to act like a void* which is constrained to always be (void*)0. ]. I think that shows the intent of the upcoming Standard is to disallow implicit conversion from nullptr to other integral types, as an implicit conversion from (void*)0 to int would be disallowed. -- mdorey at bluearc dot com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mdorey at bluearc dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35669