From patchwork Mon Apr 4 17:26:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 605945 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3qdzSD0YpVz9sBM for ; Tue, 5 Apr 2016 03:26:51 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=M/5wtdsO; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=x0m44qv+fl1OD6LojZyPNqvJ+uop8dF9cPAaUj48eWQb8AU3c/ pYE5+PvMoull6R3Oru6u4YlR6MW5isgif9PlmznJoglSda39tuEI5yi/MB8Ipn9m z14pzI5RqKUcUZUenYsovMRPdz2hl9HmvVtBzdiwsU/f9ioMDCGzNy13w= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=8hiyrG1DdapIdw/CQsr3jqcIrQ0=; b=M/5wtdsODrdOLKTbN0Mq y2JK9/C77h4Bb6CkK2B7k/4pYTh9x9TwLnnlpcY/9zTBx3MGMMCbWcWjns2lFT3T 812R7pWgMJ7CYVFqFOQWcMSqxuMWeKDulNlY7BtSRjLqI1mLi42wA+C/RRUjTnZl bF/BUbJzyVJj4Kyd1fLF3k8= Received: (qmail 39693 invoked by alias); 4 Apr 2016 17:26:44 -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 39677 invoked by uid 89); 4 Apr 2016 17:26:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=HX-Received:10.98.14.207, meet X-HELO: mail-pf0-f172.google.com Received: from mail-pf0-f172.google.com (HELO mail-pf0-f172.google.com) (209.85.192.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 04 Apr 2016 17:26:33 +0000 Received: by mail-pf0-f172.google.com with SMTP id 184so48669398pff.0 for ; Mon, 04 Apr 2016 10:26:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:to:cc:from:subject:message-id:date :user-agent:mime-version; bh=R1MfLFovsS/rxuFn7lbvrbUnWBfovcaPa6txPyWiZ14=; b=LQYy5ghBouZ7DODStPW+hTvS9xo2POtEHObQLRw1D0/Xm3vR8BPRxPTPZ+PF4DlZIs iPFCFoaLd8BigghSujdtjQKCIeRL4L7uvYpgnph61kXJBJJpPB3Lt89YErBiXoSyn/lP bgFeRqWqBifeIbiZrNTwHC9Wq4KxyQjKhttInRSuV8mnnYLNxtbk9dqbiGzv58WdWFPG krfifzDKUqcZ1Q42I0F+Ojpy2B/dWOqYbKAtOrsl4KyyqwYiuzuGTsJCBwX4RU6G9EUn nPaKlbqUVZn/LTt5Dm/MbW8XckLoIfk1EbQcjj2VthqNnR+Wrz1Cx5gjaMXH66DwrHJt QYrg== X-Gm-Message-State: AD7BkJLJsGAkXoeV9oiIorcRNDQ/t64+Lf6So1zW/fy3JerwH9LfhLDHIa4us6JhyPHDdQ== X-Received: by 10.98.14.207 with SMTP id 76mr22470845pfo.1.1459790791819; Mon, 04 Apr 2016 10:26:31 -0700 (PDT) Received: from ?IPv6:2600:1010:b161:d5a3:a2a8:cdff:fe3e:b48? ([2600:1010:b161:d5a3:a2a8:cdff:fe3e:b48]) by smtp.googlemail.com with ESMTPSA id w62sm40874844pfa.79.2016.04.04.10.26.30 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 04 Apr 2016 10:26:30 -0700 (PDT) To: Jason Merrill Cc: GCC Patches From: Nathan Sidwell Subject: [C++ PATCH] PR 70501, ICE in verify ctor sanity Message-ID: <5702A3C5.20103@acm.org> Date: Mon, 4 Apr 2016 10:26:29 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70501 This fixes 70501. The cause is an omission in typeck when converting a scalar operand to a vector. We use build_vector_from_val, which can return a CONSTRUCTOR. We fail to wrap that CONSTRUCTOR in a TARGET_EXPR. The ICE arises because at the point we meet that CONSTRUCTOR during the constexpr processing, the currently active object under construction is that for the result of the <= operator, which has type vector-of-bool, rather than vector-of-int. (thus this problem arises in other vector ops, but mostly undetected because the result type is the same as the operand type) ok? nathan 2016-04-04 Nathan Sidwell PR c++/70501 * typeck.c (cp_build_binary_op): Wrap vector constructors in target_exprs. * g++.dg/init/pr70501.C: New. Index: cp/typeck.c =================================================================== --- cp/typeck.c (revision 234715) +++ cp/typeck.c (working copy) @@ -4196,6 +4196,8 @@ cp_build_binary_op (location_t location, op0 = convert (TREE_TYPE (type1), op0); op0 = save_expr (op0); op0 = build_vector_from_val (type1, op0); + if (TREE_CODE (op0) == CONSTRUCTOR) + op0 = get_target_expr (op0); type0 = TREE_TYPE (op0); code0 = TREE_CODE (type0); converted = 1; @@ -4206,6 +4208,8 @@ cp_build_binary_op (location_t location, op1 = convert (TREE_TYPE (type0), op1); op1 = save_expr (op1); op1 = build_vector_from_val (type0, op1); + if (TREE_CODE (op1) == CONSTRUCTOR) + op1 = get_target_expr (op1); type1 = TREE_TYPE (op1); code1 = TREE_CODE (type1); converted = 1; Index: testsuite/g++.dg/init/pr70501.C =================================================================== --- testsuite/g++.dg/init/pr70501.C (nonexistent) +++ testsuite/g++.dg/init/pr70501.C (working copy) @@ -0,0 +1,11 @@ +/* { dg-options "" } Not pedantic */ + +typedef int v4si __attribute__ ((vector_size (16))); + +struct S { v4si v; }; + +void +fn2 (int i, int j) +{ + struct S s = { .v = i <= j + (v4si){(1, 2)} }; +}