From patchwork Thu Apr 5 17:11:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 895459 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-475948-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="tvOaSp7P"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40H8WY5sDHz9ryk for ; Fri, 6 Apr 2018 03:11:53 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=rLOFTLhN9zlTwpeIO9zRvKWW3BGaM5rFEUGHv8WeXfHAgg 8kNhoa2+MnOHC3hfSGefXngJ/1H9d3uysYtTzWZ/1O9/bQ+pLWmXUMWmEERTaJP1 6/Wfxanypw9Zy+RmrO/vggTOU51iDL8u7JVzP0g+JIvzg2t+0ztHzDHUbEHJU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=nXIGrL29Kldxl1wWN3DE9Vkzvvs=; b=tvOaSp7Pu93GXnn6b34N xnnDUEFc2GLAvjIMde/HYP0O/Yno1vbelIBHCpvTncsdZrglFP7s1odbPB5qXXoK p5+3XQTWF7ibUetmWBxWKoUYexYTn0a2ycLFAcdVfAsxhMa2VI9Prc3nAllnsd7o voB0AilH/auYbyIe+XGnhig= Received: (qmail 78767 invoked by alias); 5 Apr 2018 17:11:46 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 78757 invoked by uid 89); 5 Apr 2018 17:11:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=our X-HELO: mail-ot0-f176.google.com Received: from mail-ot0-f176.google.com (HELO mail-ot0-f176.google.com) (74.125.82.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Apr 2018 17:11:44 +0000 Received: by mail-ot0-f176.google.com with SMTP id h55-v6so26493487ote.9 for ; Thu, 05 Apr 2018 10:11:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=yB6yg/kKg3l0jsblRrbhY02kLsKNUXlDP6Rvr95bjBE=; b=IFChJC7jT+bcngft4oBBo2vmK6G2X/RENAymsdRA4/F+CW2mKgmTUOy6LUSk41bGCA OiP7XraLMbjxR85uIxoFhCCSA9pkBSzwvfUQa5nCEovcpyWy7lh5gn5FlJ+Dja+hLoex opHsPgnMsDWe5LtxoR4s+0ZGpjy1Sp37IhZiZegbSfFmo7ItWtCXcD680TDkYI0/Iiv1 pKsQ1Jh7JDqrroWd7DVYby+dH6pFQJ11iVYxmVpXTvePyoWHdfBMbZ85DijdpC2YA4Ww aJq6rkrb3woKnBCd+FaEl8kECahCNuQTUuPVwCdlV5XfK3sW7ywJZY914BnfFyXarMFj 6GSw== X-Gm-Message-State: ALQs6tBQyk3rklJcwOYKIQ7EqyzMFfbJLtSoAlG5VmCXSM0NRFJAmkXc u3AoASRAsf7iNd9O9ltF+VismR/wF9W6c+oZPYEYeQh8 X-Google-Smtp-Source: AIpwx4+52DV+KtqR7resIFXZVJxYgDVKneS7RSofdRpHgiAYpm60SCQdQEUYLRbSpJXpBtoEiPFzezKM0RhcDEeoJBQ= X-Received: by 2002:a9d:e84:: with SMTP id 4-v6mr14801640otj.14.1522948302645; Thu, 05 Apr 2018 10:11:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.201.7.234 with HTTP; Thu, 5 Apr 2018 10:11:22 -0700 (PDT) From: Jason Merrill Date: Thu, 5 Apr 2018 13:11:22 -0400 Message-ID: Subject: C++ PATCH for c++/83808, ICE with VLA initialization To: gcc-patches List X-IsSubscribed: yes Since my patch for 69847 stopped us from giving a STRING_CST VLA type, the check in process_init_constructor_array to make sure our initializer has the right type breaks. Let's just adjust the sanity check to look through arrays rather than try to be more specific. Tested x86_64-pc-linux-gnu, applying to trunk. commit 44cef54536ebec8b054767235330bfb86bea912f Author: Jason Merrill Date: Thu Apr 5 12:01:35 2018 -0400 PR c++/83808 - ICE with VLA initialization. * typeck2.c (process_init_constructor_array): Don't require a VLA initializer to have VLA type. diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 3bdeae1501f..e5f9a68ec58 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1319,9 +1319,11 @@ process_init_constructor_array (tree type, tree init, int nested, ce->value = massage_init_elt (TREE_TYPE (type), ce->value, nested, complain); - if (ce->value != error_mark_node) - gcc_assert (same_type_ignoring_top_level_qualifiers_p - (TREE_TYPE (type), TREE_TYPE (ce->value))); + gcc_checking_assert + (ce->value == error_mark_node + || (same_type_ignoring_top_level_qualifiers_p + (strip_array_types (TREE_TYPE (type)), + strip_array_types (TREE_TYPE (ce->value))))); flags |= picflag_from_initializer (ce->value); } diff --git a/gcc/testsuite/g++.dg/ext/vla19.C b/gcc/testsuite/g++.dg/ext/vla19.C new file mode 100644 index 00000000000..287a0d5a381 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/vla19.C @@ -0,0 +1,16 @@ +// PR c++/83808 +// { dg-additional-options "-Wno-vla" } + +struct R { int r; }; +void baz (char *, char *, char *, char *); + +void +foo () +{ + const R a = { 12 }; + char b[1][a.r] = { { "12345678901" } }; + char c[a.r] = { "12345678901" }; + char d[1][a.r] = { { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '\0' } }; + char e[a.r] = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '\0' }; + baz (b[0], c, d[0], e); +}