Message ID | 20181212161330.GA2560@redhat.com |
---|---|
State | New |
Headers | show |
Series | PR libstdc++/80762 avoid ambiguous __constructible_from<void, void> | expand |
On Wed, 12 Dec 2018 at 17:13, Jonathan Wakely <jwakely@redhat.com> wrote: > > Ensure we don't try to instantiate __is_constructible_from<void, void>, > 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. > Hi Jonathan, One of the new tests fails on bare-metal/newlib targets (aarch64-elf/arm-eabi): FAIL: experimental/filesystem/path/construct/80762.cc (test for excess errors) /libstdc++-v3/testsuite/experimental/filesystem/path/construct/80762.cc:20: fatal error: experimental/filesystem: No such file or directory I think there was a similar issue recently, but I don't remember how you fixed it? Thanks > Tested x86_64-linux (and manually verified it fixes the clang errors). > > Committed to trunk. This is worth backporting too, I think. >
On 13/12/18 08:56 +0100, Christophe Lyon wrote: >On Wed, 12 Dec 2018 at 17:13, Jonathan Wakely <jwakely@redhat.com> wrote: >> >> Ensure we don't try to instantiate __is_constructible_from<void, void>, >> 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. >> > >Hi Jonathan, > >One of the new tests fails on bare-metal/newlib targets (aarch64-elf/arm-eabi): >FAIL: experimental/filesystem/path/construct/80762.cc (test for excess errors) >/libstdc++-v3/testsuite/experimental/filesystem/path/construct/80762.cc:20: >fatal error: experimental/filesystem: No such file or directory > >I think there was a similar issue recently, but I don't remember how >you fixed it? Like this. Sorry for forgetting it. Committed to trunk. Aside: There's actually no reason the filesystem::path type can't be enabled unconditionally for all targets, as it only relies on portable features like std::string, but currently the definitions of its member functions are in the libstdc++fs.a library which is only enabled conditionally. Later today I plan to move the std::filesystem::path type into the main libstdc++.so library, so only the tests for std::experimental::filesystem::path will depend on libstdc++fs.a being available. Until then, this patch is needed. commit e9d4b85b9d8f91743617729d0a1e6a9f9a39e37d Author: Jonathan Wakely <jwakely@redhat.com> Date: Thu Dec 13 10:56:46 2018 +0000 Disable new tests for configurations with no libstdc++fs.a * testsuite/27_io/filesystem/path/construct/80762.cc: Skip test if the Filesystem TS support is not configured. * testsuite/experimental/filesystem/path/construct/80762.cc: Likewise. diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/construct/80762.cc b/libstdc++-v3/testsuite/27_io/filesystem/path/construct/80762.cc index 15a79fd4e12..0137e4466d0 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/path/construct/80762.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/path/construct/80762.cc @@ -17,6 +17,7 @@ // { dg-options "-std=gnu++17" } // { dg-do compile { target c++17 } } +// { dg-require-filesystem-ts "" } #include <filesystem> diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/construct/80762.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/construct/80762.cc index fdd9f768f78..84ea48b11b1 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/path/construct/80762.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/construct/80762.cc @@ -16,6 +16,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile { target c++11 } } +// { dg-require-filesystem-ts "" } #include <experimental/filesystem>
On Thu, 13 Dec 2018 at 12:00, Jonathan Wakely <jwakely@redhat.com> wrote: > > On 13/12/18 08:56 +0100, Christophe Lyon wrote: > >On Wed, 12 Dec 2018 at 17:13, Jonathan Wakely <jwakely@redhat.com> wrote: > >> > >> Ensure we don't try to instantiate __is_constructible_from<void, void>, > >> 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. > >> > > > >Hi Jonathan, > > > >One of the new tests fails on bare-metal/newlib targets (aarch64-elf/arm-eabi): > >FAIL: experimental/filesystem/path/construct/80762.cc (test for excess errors) > >/libstdc++-v3/testsuite/experimental/filesystem/path/construct/80762.cc:20: > >fatal error: experimental/filesystem: No such file or directory > > > >I think there was a similar issue recently, but I don't remember how > >you fixed it? > > Like this. Sorry for forgetting it. Committed to trunk. OK thanks. Note that only the one in "experimental" failed, the 27_io one did pass. > > Aside: > There's actually no reason the filesystem::path type can't be enabled > unconditionally for all targets, as it only relies on portable > features like std::string, but currently the definitions of its member > functions are in the libstdc++fs.a library which is only enabled > conditionally. Later today I plan to move the std::filesystem::path > type into the main libstdc++.so library, so only the tests for > std::experimental::filesystem::path will depend on libstdc++fs.a being > available. Until then, this patch is needed. > Great!
On 13/12/18 13:10 +0100, Christophe Lyon wrote: >On Thu, 13 Dec 2018 at 12:00, Jonathan Wakely <jwakely@redhat.com> wrote: >> >> On 13/12/18 08:56 +0100, Christophe Lyon wrote: >> >On Wed, 12 Dec 2018 at 17:13, Jonathan Wakely <jwakely@redhat.com> wrote: >> >> >> >> Ensure we don't try to instantiate __is_constructible_from<void, void>, >> >> 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. >> >> >> > >> >Hi Jonathan, >> > >> >One of the new tests fails on bare-metal/newlib targets (aarch64-elf/arm-eabi): >> >FAIL: experimental/filesystem/path/construct/80762.cc (test for excess errors) >> >/libstdc++-v3/testsuite/experimental/filesystem/path/construct/80762.cc:20: >> >fatal error: experimental/filesystem: No such file or directory >> > >> >I think there was a similar issue recently, but I don't remember how >> >you fixed it? >> >> Like this. Sorry for forgetting it. Committed to trunk. >OK thanks. >Note that only the one in "experimental" failed, the 27_io one did pass. Because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86756 :-) The <filesystem> header is installed unconditionally, and that test only needs the header not the library, so it happens to work. The <experimental/filesystem> header is only installed when libstdc++fs.a is available. >> >> Aside: >> There's actually no reason the filesystem::path type can't be enabled >> unconditionally for all targets, as it only relies on portable >> features like std::string, but currently the definitions of its member >> functions are in the libstdc++fs.a library which is only enabled >> conditionally. Later today I plan to move the std::filesystem::path >> type into the main libstdc++.so library, so only the tests for >> std::experimental::filesystem::path will depend on libstdc++fs.a being >> available. Until then, this patch is needed. >> >Great!
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<typename _Tp1, typename _Tp2 = void> using _Path = typename - std::enable_if<__and_<__not_<is_same<_Tp1, path>>, + std::enable_if<__and_<__not_<is_same<remove_cv_t<_Tp1>, path>>, + __not_<is_void<_Tp1>>, __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<typename _Tp1, typename _Tp2 = void> using _Path = typename - std::enable_if<__and_<__not_<is_same<_Tp1, path>>, + std::enable_if<__and_<__not_<is_same<typename remove_cv<_Tp1>::type, + path>>, + __not_<is_void<_Tp1>>, __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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include <filesystem> + +using std::filesystem::path; + +static_assert( !std::is_constructible_v<path, void> ); +static_assert( !std::is_constructible_v<path, volatile path> ); +static_assert( !std::is_constructible_v<path, volatile path&> ); +static_assert( !std::is_constructible_v<path, const volatile path> ); +static_assert( !std::is_constructible_v<path, const volatile path&> ); 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile { target c++11 } } + +#include <experimental/filesystem> + +using std::experimental::filesystem::path; + +static_assert( !std::is_constructible<path, void>::value, "" ); +static_assert( !std::is_constructible<path, volatile path>::value, "" ); +static_assert( !std::is_constructible<path, volatile path&>::value, "" ); +static_assert( !std::is_constructible<path, const volatile path>::value, "" ); +static_assert( !std::is_constructible<path, const volatile path&>::value, "" );