From 6b7c0b5559316028d392d2bf9a4a0ca9e7562ce7 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 12 Dec 2018 16:13:43 +0000 Subject: [PATCH] PR libstdc++/80762 avoid ambiguous __constructible_from Ensure we don't try to instantiate __is_constructible_from, because there are two partial specializations that are equally good matches. PR libstdc++/80762 * include/bits/fs_path.h (path::_Path): Use remove_cv_t and is_void. * include/experimental/bits/fs_path.h (path::_Path): Likewise. * testsuite/27_io/filesystem/path/construct/80762.cc: New test. * testsuite/experimental/filesystem/path/construct/80762.cc: New test. From-SVN: r267056 --- libstdc++-v3/ChangeLog | 8 +++++ libstdc++-v3/include/bits/fs_path.h | 3 +- .../include/experimental/bits/fs_path.h | 4 ++- .../27_io/filesystem/path/construct/80762.cc | 29 +++++++++++++++++++ .../filesystem/path/construct/80762.cc | 28 ++++++++++++++++++ 5 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 libstdc++-v3/testsuite/27_io/filesystem/path/construct/80762.cc create mode 100644 libstdc++-v3/testsuite/experimental/filesystem/path/construct/80762.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 81dc78be260..886253db410 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2018-12-12 Jonathan Wakely + + PR libstdc++/80762 + * include/bits/fs_path.h (path::_Path): Use remove_cv_t and is_void. + * include/experimental/bits/fs_path.h (path::_Path): Likewise. + * testsuite/27_io/filesystem/path/construct/80762.cc: New test. + * testsuite/experimental/filesystem/path/construct/80762.cc: New test. + 2018-12-12 Jakub Jelinek P0595R2 - is_constant_evaluated diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h index 0eee684a2f6..cbaea7343a3 100644 --- a/libstdc++-v3/include/bits/fs_path.h +++ b/libstdc++-v3/include/bits/fs_path.h @@ -110,7 +110,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 template using _Path = typename - std::enable_if<__and_<__not_>, + std::enable_if<__and_<__not_, path>>, + __not_>, __constructible_from<_Tp1, _Tp2>>::value, path>::type; diff --git a/libstdc++-v3/include/experimental/bits/fs_path.h b/libstdc++-v3/include/experimental/bits/fs_path.h index 653b4a3fe85..340cc59d541 100644 --- a/libstdc++-v3/include/experimental/bits/fs_path.h +++ b/libstdc++-v3/include/experimental/bits/fs_path.h @@ -125,7 +125,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 template using _Path = typename - std::enable_if<__and_<__not_>, + std::enable_if<__and_<__not_::type, + path>>, + __not_>, __constructible_from<_Tp1, _Tp2>>::value, path>::type; diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/construct/80762.cc b/libstdc++-v3/testsuite/27_io/filesystem/path/construct/80762.cc new file mode 100644 index 00000000000..15a79fd4e12 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/filesystem/path/construct/80762.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2018 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 + +using std::filesystem::path; + +static_assert( !std::is_constructible_v ); +static_assert( !std::is_constructible_v ); +static_assert( !std::is_constructible_v ); +static_assert( !std::is_constructible_v ); +static_assert( !std::is_constructible_v ); diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/construct/80762.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/construct/80762.cc new file mode 100644 index 00000000000..fdd9f768f78 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/construct/80762.cc @@ -0,0 +1,28 @@ +// Copyright (C) 2018 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 + +using std::experimental::filesystem::path; + +static_assert( !std::is_constructible::value, "" ); +static_assert( !std::is_constructible::value, "" ); +static_assert( !std::is_constructible::value, "" ); +static_assert( !std::is_constructible::value, "" ); +static_assert( !std::is_constructible::value, "" );