https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70808
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> ---
In fact, there is sort-of an inconsistency in build_zero_init_1 which explains
the inconsistency in the original testcase:
else if (TYPE_PTR_OR_PTRMEM_P (type))
init = fold (convert (type, nullptr_node));
else if (SCALAR_TYPE_P (type))
init = fold (convert (type, integer_zero_node));
thus std::nullptr_t is handled as a generic scalar, whereas int* is not.
Changing the above as in the below makes sense to me and would have the effect
of suppressing the warning for both the testcases here.
Index: init.c
===================================================================
--- init.c (revision 259287)
+++ init.c (working copy)
@@ -180,7 +180,7 @@ build_zero_init_1 (tree type, tree nelts, bool sta
items with static storage duration that are not otherwise
initialized are initialized to zero. */
;
- else if (TYPE_PTR_OR_PTRMEM_P (type))
+ else if (TYPE_PTR_OR_PTRMEM_P (type) || NULLPTR_TYPE_P (type))
init = fold (convert (type, nullptr_node));
else if (SCALAR_TYPE_P (type))
init = fold (convert (type, integer_zero_node));