From patchwork Fri May 1 18:15:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ville Voutilainen X-Patchwork-Id: 1281422 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: 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=pqw+4t8P; 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49DL6J6gjlz9sTF for ; Sat, 2 May 2020 04:16:06 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B39603938C1E; Fri, 1 May 2020 18:16:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B39603938C1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1588356963; bh=1atfoG/NlKPs0zyta+NMs9Qe8o12M10a5sQKNF4xlV8=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=pqw+4t8PpLoPtFT1YyYAms4kRTLf5GEnq+fLSBA6QUy9arGeScA0J+51mY9m8DJBx Nz49WNg92coVTCuyPkd6HUatYk5Yo51qjRYdiGS5XKj07ff8reFZ2yhHitr4hKJ1FM aLWafGwNCRpbbv5VBI+suRDAAK5y9wl536Yxk96s= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by sourceware.org (Postfix) with ESMTPS id C2A373851C31; Fri, 1 May 2020 18:16:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C2A373851C31 Received: by mail-qk1-x743.google.com with SMTP id k81so7347206qke.5; Fri, 01 May 2020 11:16:00 -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=1atfoG/NlKPs0zyta+NMs9Qe8o12M10a5sQKNF4xlV8=; b=uRbYxtXmYgnNYqxAZYfF9oBzfXi6G2mojP7iGeQc09dhEDE7ljmff1mCOxAWuhVY9H jIE3JvPj2idDKdwZH8uYwz7AZyPKaE23LSURgOoGWegDq6OxccETEFR6897juGjvuphs MxlISQJrdPqWsMtcLjjhZGu5Jfbm7ZCT0nMOKI8s2meUvRa3G84AsR+1eeKqDvcfYuvj QRzTQB1a8ARCvIIuSDzM/bPzUje7yHK85SxEupXs5bXm69CjU0hxrWHVwEntMjgZr8aI RcSn3eKK/tVhB2BaYuhiJca9wZmQhS5HWO8hAMfypMIQXoaU7931FrvJezFU+WuyD6JY YcIg== X-Gm-Message-State: AGi0PuZGRpaMXAuB+Ud0MrZQvHqwFGj9QhEC7YiRXhYudhfusxzX4sUg Y3wCzACdxDMgYItAjJRfecGBGwNw66v3XH732c4eyOTf8hA= X-Google-Smtp-Source: APiQypKkL1+kxun7AVmI/sqLpcNhhN/K2dTfUmkhtKmHrIyhbo2jLtFlDrkRcEiU2yagi00TNHkG6zELktPJ3W/JB4w= X-Received: by 2002:a37:9b0f:: with SMTP id d15mr4977368qke.62.1588356959964; Fri, 01 May 2020 11:15:59 -0700 (PDT) MIME-Version: 1.0 Date: Fri, 1 May 2020 21:15:48 +0300 Message-ID: Subject: [PATCH] libstdc++: Fix tuple and optional construction from {aggregate_member_value} (libstdc++/94890) To: "libstdc++" , gcc-patches List X-Spam-Status: No, score=-15.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Ville Voutilainen via Gcc-patches From: Ville Voutilainen Reply-To: Ville Voutilainen Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Aggregate-paren-init breaks tuple and optional. This fixes the breakage. An LWG issue will be filed. Full suite test run pending. Ok for master and gcc-10 if the full tests pass? 2020-05-01 Ville Voutilainen PR libstdc++/94890 * include/std/optional (optional(_Up&&)): Add is_aggregate to the convertibility constraints. * include/std/tuple (__is_implicitly_constructible) (__is_explicitly_constructible): Likewise. * testsuite/20_util/optional/cons/94890.cc: New. * testsuite/20_util/tuple/cons/94890.cc: Likewise. diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional index 37c2ba7a025..e0e307bc5f5 100644 --- a/libstdc++-v3/include/std/optional +++ b/libstdc++-v3/include/std/optional @@ -696,7 +696,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template, __not_tag<_Up>, is_constructible<_Tp, _Up&&>, +#if __cpp_aggregate_paren_init + __or_, + is_convertible<_Up&&, _Tp>>> = true> +#else is_convertible<_Up&&, _Tp>> = true> +#endif constexpr optional(_Up&& __t) : _Base(std::in_place, std::forward<_Up>(__t)) { } @@ -704,7 +709,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template, __not_tag<_Up>, is_constructible<_Tp, _Up&&>, +#if __cpp_aggregate_paren_init + __not_<__or_, + is_convertible<_Up&&, _Tp>>>> = false> +#else __not_>> = false> +#endif explicit constexpr optional(_Up&& __t) : _Base(std::in_place, std::forward<_Up>(__t)) { } diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index db4872d3a52..7744d9c402d 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -467,7 +467,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static constexpr bool __is_implicitly_constructible() { return __and_..., +#if __cpp_aggregate_paren_init + __or_, + is_convertible<_UTypes, _Types>>... +#else is_convertible<_UTypes, _Types>... +#endif >::value; } @@ -478,8 +483,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static constexpr bool __is_explicitly_constructible() { return __and_..., - __not_<__and_...>> - >::value; + __not_<__and_< +#if __cpp_aggregate_paren_init + __or_, + is_convertible<_UTypes, _Types>>...> +#else + is_convertible<_UTypes, _Types>...> +#endif + >>::value; } static constexpr bool __is_implicitly_default_constructible() diff --git a/libstdc++-v3/testsuite/20_util/optional/cons/94890.cc b/libstdc++-v3/testsuite/20_util/optional/cons/94890.cc new file mode 100644 index 00000000000..f66ddb7db13 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/optional/cons/94890.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "--std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include + +struct c { int i; }; + +std::optional x({0}); + diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/94890.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/94890.cc new file mode 100644 index 00000000000..76b99c9fd05 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/94890.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile { target c++11 } } + +#include + +struct c { int i; }; + +std::tuple x({0}); +