https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94510
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org Status|NEW |ASSIGNED --- Comment #9 from Martin Sebor <msebor at gcc dot gnu.org> --- The changed code in reshape_init_array_1 checks for integer/pointer mismatches via the following test: /* Pointers initialized to strings must be treated as non-zero even if the string is empty. */ tree init_type = TREE_TYPE (elt_init); if (POINTER_TYPE_P (elt_type) != POINTER_TYPE_P (init_type) || !type_initializer_zero_p (elt_type, elt_init)) last_nonzero = index; ...and a test case involving an ordinary pointer is diagnosed: $ cat t.C && gcc -S -Wall t.C int a[2] = { nullptr }; int b[2] = { (void*)0 }; t.C:2:23: error: invalid conversion from ‘void*’ to ‘int’ [-fpermissive] 2 | int b[2] = { (void*)0 }; | ^ | | | void* but a nullptr use is not. (gdb) p debug_tree (init_type) $6 = (tree) 0x7fffea9521f8 <nullptr_type 0x7fffea9521f8 decltype(nullptr) public unsigned DI size <integer_cst 0x7fffea7f7e70 type <integer_type 0x7fffea8150a8 bitsizetype> constant 64> unit-size <integer_cst 0x7fffea7f7e88 type <integer_type 0x7fffea815000 sizetype> constant 8> align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffea9521f8> I would expect POINTER_TYPE_P (init_type) to be non-zero but it's not: (gdb) p POINTER_TYPE_P (init_type) $7 = false