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: 1730633 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=YZfxU/1p; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P12rT0gQlz23gY for ; Tue, 24 Jan 2023 08:13:09 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 14B743858401 for ; Mon, 23 Jan 2023 21:13:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 14B743858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674508381; 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=YZfxU/1ppF0CxA1myZ/dAiYZT8PnNkw0KyVMWMMoi7rUoC3D/RrEkUJG63ftxQDJU DhqJ8fbgqMlib3DlRDw1tGZXFjTw5L95vhLcR3rupwevcWyVspCI4IcFc4xhnVz3d/ c65Un7yrYmN4LhcbSzumCh33gsfHH+T55iFuGM7g= 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-Google-Smtp-Source: AMrXdXsQ41+ps86Oz9S9YZKn9a04O/RcNRU3J6Yn8RWB7dg9uy4pqmXce6spN83xCaR+v1xj9iFg/g== 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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 (); +}