diff options
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9a6c2e30e7f..02992ae9b47 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-08-01 Martin Sebor <msebor@redhat.com> + + PR c++/90947 + * decl.c (reshape_init_array_1): Avoid truncating initializer + lists containing string literals. + 2019-08-01 Marek Polacek <polacek@redhat.com> PR c++/90805 - detect narrowing in case values. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index c8b9e3b8fb9..a1ab5ca8193 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5899,8 +5899,9 @@ reshape_init_array_1 (tree elt_type, tree max_index, reshape_iter *d, /* 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)) - || !initializer_zerop (elt_init)) + if ((POINTER_TYPE_P (elt_type) != POINTER_TYPE_P (init_type))) + last_nonzero = index; + else if (!type_initializer_zero_p (elt_type, elt_init)) last_nonzero = index; /* This can happen with an invalid initializer (c++/54501). */ |