From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id 353253858C2B; Mon, 23 Jan 2023 21:13:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 353253858C2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674508380; bh=SlQKUURi5W+LUi4QoYWRxNr4LJwUOC+7bhoWS+mjtUc=; h=From:To:Subject:Date:From; b=IzemMQ3wg8Wxh5GFhzpFkDQtdm1x65+m416BvDR/VsAgDxHeuAD6GY8eOv5FF3Rus LpRPoBOxFj0GWcId71ohzGErP2lDl+y3BVddow1QNG7nURZx7OjzgsY4ngLleIUIoZ lrn0xjw623n49bZdOISVXCr1pR4NHFRgO8uSBNJc= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jason Merrill To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-5313] c++: vector of class with bool ctor [PR108195] X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 771d793df1622a476e1cf8d05f0a6aee350fa56b X-Git-Newrev: 72e46b3c7ad5e3d2c69868a510c00707c356106a Message-Id: <20230123211300.353253858C2B@sourceware.org> Date: Mon, 23 Jan 2023 21:13:00 +0000 (GMT) List-Id: https://gcc.gnu.org/g:72e46b3c7ad5e3d2c69868a510c00707c356106a commit r13-5313-g72e46b3c7ad5e3d2c69868a510c00707c356106a Author: Jason Merrill Date: Mon Jan 23 15:03:47 2023 -0500 c++: vector of class with bool ctor [PR108195] 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. Diff: --- gcc/cp/call.cc | 2 +- gcc/testsuite/g++.dg/cpp0x/initlist-vect2.C | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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 (); +}