From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 87898 invoked by alias); 26 Feb 2018 21:50:00 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 87889 invoked by uid 89); 26 Feb 2018 21:50:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: mail-io0-f195.google.com Received: from mail-io0-f195.google.com (HELO mail-io0-f195.google.com) (209.85.223.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 26 Feb 2018 21:49:58 +0000 Received: by mail-io0-f195.google.com with SMTP id g21so18893025ioj.5 for ; Mon, 26 Feb 2018 13:49:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=8tk/84yNiP7z998ZTw+RWo4MmU14XPpKwLsTF2nmSt4=; b=gK/MrG0V/F0rp2TzYXgaPAAabHsT698h2qzud4r6vmPfQKjB+22M9ePAwW6T/zq8tI /OUsg7aAGMh2DrO1GU1Z720wPKczZNIg0fdRy0NBrfOsi9Ucy5y/2f+keUJSct+oHkgz RnfyPRKrqrrlj/y02NhvFvwRN52u8AeQ9n4AplPPniEOCLiIixfv8W3DIFJFt29p7fBR lWiDPtQI0tI4AqIuuaF19rGqjQBrX2d+zHLRzPK6JsVl0UQeb1rcNjK8tpU9j3qCauZY +8aZy5FenSadiMnnrvz4u4Hk2cnyyI4X16fMz726qIoAM9x04MCQbd4XF4RZPBBXBQ2E qwgw== X-Gm-Message-State: APf1xPAM8DYMRcjATPRtVr0jefMHHARUBHRnbaM3RAnfxRipQYPjJyz0 Dk0Tz6UBzg32CzU/3m60zgbfGluTKdmA3gOwi/FgQg== X-Google-Smtp-Source: AG47ELtYhXLSDpfz4C+5kQ1VC6EcpeuN5MdOF5iYkmWpdZHurSYQL8EHXND5AOLzOQWvZRhvVbPYYjh9TJJNv2xl5f8= X-Received: by 10.107.161.200 with SMTP id k191mr12762409ioe.270.1519681797076; Mon, 26 Feb 2018 13:49:57 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.17.200 with HTTP; Mon, 26 Feb 2018 13:49:36 -0800 (PST) In-Reply-To: <20180226195745.GY5867@tucnak> References: <20180226195745.GY5867@tucnak> From: Jason Merrill Date: Mon, 26 Feb 2018 21:50:00 -0000 Message-ID: Subject: Re: [C++ PATCH] Fix ICE in cxx_eval_vec_init_1 (PR c++/84558) To: Jakub Jelinek Cc: Nathan Sidwell , gcc-patches List Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-02/txt/msg01466.txt.bz2 OK. On Mon, Feb 26, 2018 at 2:57 PM, Jakub Jelinek wrote: > Hi! > > The PR70001 optimization in cxx_eval_vec_init_1 uses > initializer_constant_valid_p (eltinit, TREE_TYPE (eltinit)) > which doesn't work if eltinit is NULL. This can happen if > *non_constant_p is true, but ctx->quiet is true as well (for > *non_constant_p && !ctx->quiet we break the cycle early). > No initializer can be treated like a valid initializer and will > have the advantage that we don't repeat the body for every array element > and just do it once. The caller will ignore the return value anyway > when *non_constant_p. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2018-02-26 Jakub Jelinek > > PR c++/84558 > * constexpr.c (cxx_eval_vec_init_1): For reuse, treat NULL eltinit like > a valid constant initializer. Formatting fixes. > > * g++.dg/cpp1y/pr84558.C: New test. > > --- gcc/cp/constexpr.c.jj 2018-02-26 10:46:02.162316172 +0100 > +++ gcc/cp/constexpr.c 2018-02-26 14:07:38.705532369 +0100 > @@ -2959,9 +2959,8 @@ cxx_eval_vec_init_1 (const constexpr_ctx > if (!lvalue_p (init)) > eltinit = move (eltinit); > eltinit = force_rvalue (eltinit, tf_warning_or_error); > - eltinit = (cxx_eval_constant_expression > - (&new_ctx, eltinit, lval, > - non_constant_p, overflow_p)); > + eltinit = cxx_eval_constant_expression (&new_ctx, eltinit, lval, > + non_constant_p, overflow_p); > } > if (*non_constant_p && !ctx->quiet) > break; > @@ -2974,12 +2973,13 @@ cxx_eval_vec_init_1 (const constexpr_ctx > else > CONSTRUCTOR_APPEND_ELT (*p, idx, eltinit); > /* Reuse the result of cxx_eval_constant_expression call > - from the first iteration to all others if it is a constant > - initializer that doesn't require relocations. */ > + from the first iteration to all others if it is a constant > + initializer that doesn't require relocations. */ > if (reuse > && max > 1 > - && (initializer_constant_valid_p (eltinit, TREE_TYPE (eltinit)) > - == null_pointer_node)) > + && (eltinit == NULL_TREE > + || (initializer_constant_valid_p (eltinit, TREE_TYPE (eltinit)) > + == null_pointer_node))) > { > if (new_ctx.ctor != ctx->ctor) > eltinit = new_ctx.ctor; > --- gcc/testsuite/g++.dg/cpp1y/pr84558.C.jj 2018-02-26 14:33:56.575318295 +0100 > +++ gcc/testsuite/g++.dg/cpp1y/pr84558.C 2018-02-26 14:33:33.142318527 +0100 > @@ -0,0 +1,6 @@ > +// PR c++/84558 > +// { dg-do compile { target c++14 } } > + > +struct A { static int i; constexpr A () { i = 0; } }; > +struct B { A a[2][3][4]; }; > +B b; > > Jakub