[conv.ptr] p1 says > A null pointer constant is an integer literal ([lex.icon]) with value zero > A null pointer constant of integral type can be converted to a prvalue of type std::nullptr_t. GCC accept this example ````cpp std::nullptr_t v = (int)0; ```` However, the initializer expression is not an integer literal, it is a prvalue of integer type with the value 0. It should be rejected. Clang rejects this example. https://godbolt.org/z/fxMo4YKE3
(In reply to jim x from comment #0) > GCC accept this example Well, it does if you include a definition of std::nullptr_t typedef decltype(nullptr) nullptr_t; nullptr_t v = (int)0; Not a regression, this has been accepted since 4.6.4
I think this is CWG 903 and thus a dup of bug 52145. The problem here is probably the same as I described in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77712#c2.
I wonder if we could wrap the INTEGER_CST in a NOP_EXPR/V_C_E to make it clear it's not an integer literal.
Dup of bug 52145. *** This bug has been marked as a duplicate of bug 52145 ***