On Tue, Dec 22, 2020 at 09:56:03AM -0500, Jason Merrill via Gcc-patches wrote:
> > Not exactly sure why we just don't call build_zero_cst (type); for the > 
> > scalar types
> 
> I don't know either.  Want to test that?

The following passed bootstrap/regtested on x86_64-linux and i686-linux too.
And the function comment even confirms the behavior we need for
build_zero_init_1:
/* Build 0 constant of type TYPE.  This is used by constructor folding
   and thus the constant should be represented in memory by
   zero(es).  */
Ok for trunk?

2020-12-23  Jakub Jelinek  <ja...@redhat.com>

        PR c++/98353
        * init.c (build_zero_init_1): Use build_zero_cst for SCALAR_TYPE_P
        zero initializers.

--- gcc/cp/init.c.jj    2020-12-09 09:03:38.270054654 +0100
+++ gcc/cp/init.c       2020-12-21 13:51:57.353332652 +0100
@@ -187,7 +187,7 @@ build_zero_init_1 (tree type, tree nelts
   else if (NULLPTR_TYPE_P (type))
     init = build_int_cst (type, 0);
   else if (SCALAR_TYPE_P (type))
-    init = fold (convert (type, integer_zero_node));
+    init = build_zero_cst (type);
   else if (RECORD_OR_UNION_CODE_P (TREE_CODE (type)))
     {
       tree field;


        Jakub

Reply via email to