https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91914
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot
gnu.org
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
I was reluctant to backport the fix for pr91490 to GCC 9 because although it
eliminates some false positives it introduces new true ones that didn't exist
before. Maybe that's okay. If not, the simple change below appears to both
avoid the false positive and the unintended folding:
Index: gcc/expr.c
===================================================================
--- gcc/expr.c (revision 276151)
+++ gcc/expr.c (working copy)
@@ -11556,7 +11556,7 @@ string_constant (tree arg, tree *ptr_offset, tree
base_off = wioff.to_uhwi ();
unsigned HOST_WIDE_INT fieldoff = 0;
- init = fold_ctor_reference (NULL_TREE, init, base_off, 0, array,
+ init = fold_ctor_reference (TREE_TYPE (arg), init, base_off, 0, array,
&fieldoff);
HOST_WIDE_INT cstoff;
if (!base_off.is_constant (&cstoff))