diff mbox

Fix PR/63841: empty constructor doesn't zero-initialize

Message ID CAAe5K+Vxtb=L3Jdkz5f-D16Y_j4Nd2FWRrF0Bmt1Gvu83YhHgg@mail.gmail.com
State New
Headers show

Commit Message

Teresa Johnson Nov. 12, 2014, 10:13 p.m. UTC
This patch fixes an issue where tree-strlen was incorrectly removing a
store of 0 into a string because it thought a prior CLOBBER (which is
an empty constructor with no elements) was zero-initializing the
string.

Bootstrapped and tested on x86_64-unknown-linux-gnu. OK for trunk?

Thanks,
Teresa

2014-11-12    <tejohnson@google.com>

        PR tree-optimization/63841
        * tree.c (initializer_zerop): A constructor with no elements
        does not zero initialize.

Comments

Xinliang David Li Nov. 12, 2014, 10:17 p.m. UTC | #1
missing test case?

David

On Wed, Nov 12, 2014 at 2:13 PM, Teresa Johnson <tejohnson@google.com> wrote:
> This patch fixes an issue where tree-strlen was incorrectly removing a
> store of 0 into a string because it thought a prior CLOBBER (which is
> an empty constructor with no elements) was zero-initializing the
> string.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu. OK for trunk?
>
> Thanks,
> Teresa
>
> 2014-11-12    <tejohnson@google.com>
>
>         PR tree-optimization/63841
>         * tree.c (initializer_zerop): A constructor with no elements
>         does not zero initialize.
>
> Index: tree.c
> ===================================================================
> --- tree.c      (revision 217190)
> +++ tree.c      (working copy)
> @@ -10330,6 +10330,8 @@ initializer_zerop (const_tree init)
>        {
>         unsigned HOST_WIDE_INT idx;
>
> +        if (!CONSTRUCTOR_NELTS (init))
> +          return false;
>         FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (init), idx, elt)
>           if (!initializer_zerop (elt))
>             return false;
>
>
> --
> Teresa Johnson | Software Engineer | tejohnson@google.com | 408-460-2413
diff mbox

Patch

Index: tree.c
===================================================================
--- tree.c      (revision 217190)
+++ tree.c      (working copy)
@@ -10330,6 +10330,8 @@  initializer_zerop (const_tree init)
       {
        unsigned HOST_WIDE_INT idx;

+        if (!CONSTRUCTOR_NELTS (init))
+          return false;
        FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (init), idx, elt)
          if (!initializer_zerop (elt))
            return false;