From patchwork Mon Jan 23 21:12:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 47407 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1818366wrn; Mon, 23 Jan 2023 13:13:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXvm5/KSdRowCQuyFshSipdXAM13POGBlbU0EBeaspzSuQPxPG/4xbUo2GM/tvYWOtKNvOdT X-Received: by 2002:a17:906:29d8:b0:86f:a1fe:237a with SMTP id y24-20020a17090629d800b0086fa1fe237amr26388071eje.54.1674508413133; Mon, 23 Jan 2023 13:13:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674508413; cv=none; d=google.com; s=arc-20160816; b=i9UILHL3FSDJK6jXOWJpEl9q2jH8yAM3a1ZyK+SotXNJWGqF0J04vuSHHbrjI0FCzi H76ZJxhZxTwXgFTGlt68SyZroMTdVmR1N+W14jgGxMMlwq5+QilnILeZA5zLAcsAiSQZ dw7pL61hOnKzVBDO4zZnWdwCuYtgmq1feGwqzrn+UOzYg+PZVV3UMaKan2UMi6b2q8Pf IyrJh32iJ+BYZzUKx2XYjrk3OJ430Q19w54efO+eWz+/am4JPo4+38ew6h8CbwMwgJPB VruK1vr/4qT9He1MGDG9TiJlEBfBJwKfaxO7EzCkrVjwGrtsNqOuzcbQf/7164A6uU2d NfWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=TTdt5OThjDZh/hHWleeQDF+BeXkUg4XTCbdGw1+tdhM=; b=aCL44WAC6ZQLgNvJfmW5TmSgATSA17iQLbJ8a2t5YjGYqf2UwoI0w1lhTMF/CIsqzw 7nXXn0K74KolKkSjTk+W26NZwbwZvTiZMfG4zE3IVKBOmGq9Ewpe8mBqetJFfu91mEdJ vlmujxQrFtH7Lsj0Xdd0f7W6NwhOKYfZGZdqGzUaDd9QU4UZTQ23Sr3ZsuO/AZHeUfzr wVGw+Z1eVwW0KhPNo0+JzCb7HLfKT5o6pUVbepWANu5UDXvnvQYxNrAz6DAG/K/Q/VWA 59u40MrceqOIO6BABD9D8/xh0Fc1DaDGSIsFULMsjKwXcgp+ckHJt1mvFS2zF/ac2/B9 2PLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=GrUUfVTT; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id q6-20020a1709064cc600b0084d197a89e7si24919756ejt.806.2023.01.23.13.13.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 13:13:33 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=GrUUfVTT; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F3E8F38582A4 for ; Mon, 23 Jan 2023 21:13:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F3E8F38582A4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674508406; bh=TTdt5OThjDZh/hHWleeQDF+BeXkUg4XTCbdGw1+tdhM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=GrUUfVTTu5206lcdrf17rORhXdzzOrycEPRSjqj33xSaY7Fwnn5AdUDgC6knFtO6O L+9dXj5SNuZJAyERZ7y0UhVanIf8vbNrI/+kXCdxfolYYiJVEwM4m/OgTyfZHsWjZr ihof8onv6kDDMGM6TAD5hDVfgP4FjmgvJZnl9CCQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 59A7C3858CDB for ; Mon, 23 Jan 2023 21:12:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 59A7C3858CDB Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-237-WXOvYro4O0KFTeSdOZ-K_Q-1; Mon, 23 Jan 2023 16:12:39 -0500 X-MC-Unique: WXOvYro4O0KFTeSdOZ-K_Q-1 Received: by mail-qk1-f199.google.com with SMTP id de37-20020a05620a372500b00707391077b4so9699066qkb.17 for ; Mon, 23 Jan 2023 13:12:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TTdt5OThjDZh/hHWleeQDF+BeXkUg4XTCbdGw1+tdhM=; b=EAirEqT2o/iPD46QeoLmt2bCwQd1i4K5I7uNN/XtVVzngzEr1CCPisG29qUnb1XjKP RBRaQuEo+bAmcJTcWcWNs09siUPuaI2AMHnwmEtng+MCMCDLXQyav+334VmQUW+3SAqf qa55uuUH7RhPlvi3sMjzZgPCtBVAG2moCwhiB2AgTVZo/0aRMOV59MSvinz4tzrjelL+ tFhzldd6ycbm5y5a1f/bH9xbK2M5XW8zPik2o515K1vabf+G9PmPr9VURPi/v20Qz20R vHTaH3ORa3BRLRyPRY6+GpyoM5nfPXzkZxDMRcBChErKQD+nRRQOmzmxcCnuWeO41x6z QePg== X-Gm-Message-State: AFqh2krefpHMOWqnu1TQBzpjFj5WpG83aTHMCfONwYaTj9xGCmycrZpT /AuDmWRFluGJCJ2cBE5PRnz/XtwuMDJaEJ0yIREjT7VsO1NnS9TRlNzwAgUFWgu7DKlJ+hNFcpO yGjXNfEMqIgZlAcbs3ajRx6oE0LxmEx1zEXsvqmIRrqZtvy3QCDl4s9BRSQ07zyHFig== X-Received: by 2002:ac8:748f:0:b0:3b6:2f46:937c with SMTP id v15-20020ac8748f000000b003b62f46937cmr36816888qtq.37.1674508358909; Mon, 23 Jan 2023 13:12:38 -0800 (PST) X-Received: by 2002:ac8:748f:0:b0:3b6:2f46:937c with SMTP id v15-20020ac8748f000000b003b62f46937cmr36816859qtq.37.1674508358479; Mon, 23 Jan 2023 13:12:38 -0800 (PST) Received: from jason.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id a17-20020ac86111000000b003b68c7aeebfsm20386qtm.3.2023.01.23.13.12.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 13:12:37 -0800 (PST) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: vector of class with bool ctor [PR108195] Date: Mon, 23 Jan 2023 16:12:34 -0500 Message-Id: <20230123211234.37680-1-jason@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755849333841491830?= X-GMAIL-MSGID: =?utf-8?q?1755849333841491830?= Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- The transformation done by r13-4564 to use the iterator constructor instead of the initializer-list constructor breaks if the iterator pointers are themselves treated as elements of an initializer-list, so check for that. PR c++/108195 gcc/cp/ChangeLog: * call.cc (build_user_type_conversion_1): Check whether the iterators also find a list ctor. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/initlist-vect2.C: New test. --- gcc/cp/call.cc | 2 +- gcc/testsuite/g++.dg/cpp0x/initlist-vect2.C | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist-vect2.C base-commit: 4b125d01a5d5e601961419396332b74eea2219bb diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index a7de0e8e9a6..5715a7cd1de 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -4581,7 +4581,7 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags, if (tree iters = maybe_init_list_as_range (cand->fn, expr)) if (z_candidate *cand2 = build_user_type_conversion_1 (totype, iters, flags, tf_none)) - if (cand2->viable == 1) + if (cand2->viable == 1 && !is_list_ctor (cand2->fn)) { cand = cand2; expr = iters; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-vect2.C b/gcc/testsuite/g++.dg/cpp0x/initlist-vect2.C new file mode 100644 index 00000000000..eec7d340fd1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-vect2.C @@ -0,0 +1,16 @@ +// PR c++/108195 +// { dg-do run { target c++11 } } + +#include + +struct S +{ + S(bool) {} +}; + +int main() +{ + std::vector v = { true, false, true }; + if (v.size() != 3) + __builtin_abort (); +}