PR libstdc++/90454.cc path construction from void*
authorJonathan Wakely <jwakely@redhat.com>
Mon, 13 May 2019 20:12:06 +0000 (21:12 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 13 May 2019 20:12:06 +0000 (21:12 +0100)
Make the filesystem::path constructors SFINAE away for void* arguments,
instead of giving an error due to iterator_traits<void*>::reference.

PR libstdc++/90454.cc path construction from void*
* include/bits/fs_path.h (path::_Path): Use remove_pointer so that
pointers to void are rejected as well as void.
* include/experimental/bits/fs_path.h (path::_Path): Likewise.
* testsuite/27_io/filesystem/path/construct/80762.cc: Also check
pointers to void.
* testsuite/experimental/filesystem/path/construct/80762.cc: Likewise.

From-SVN: r271134

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/fs_path.h
libstdc++-v3/include/experimental/bits/fs_path.h
libstdc++-v3/testsuite/27_io/filesystem/path/construct/80762.cc
libstdc++-v3/testsuite/experimental/filesystem/path/construct/80762.cc

index afd1b3c47f86e621126c84ff33f4ebbac79f2619..c25f2ac76414e7ad95a09442c5d4ab73e0d326dc 100644 (file)
@@ -1,5 +1,13 @@
 2019-05-13  Jonathan Wakely  <jwakely@redhat.com>
 
+       PR libstdc++/90454.cc path construction from void*
+       * include/bits/fs_path.h (path::_Path): Use remove_pointer so that
+       pointers to void are rejected as well as void.
+       * include/experimental/bits/fs_path.h (path::_Path): Likewise.
+       * testsuite/27_io/filesystem/path/construct/80762.cc: Also check
+       pointers to void.
+       * testsuite/experimental/filesystem/path/construct/80762.cc: Likewise.
+
        * doc/xml/manual/policy_data_structures.xml: Comment out stray
        <remark> elements. Fix formatting of bibliography references.
 
index d1ad11a60c43ca56c7def23ebf24c15866b4aae2..cec35614b42570764d18f080c461063ee1815ba0 100644 (file)
@@ -115,7 +115,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
     template<typename _Tp1, typename _Tp2 = void>
       using _Path = typename
        std::enable_if<__and_<__not_<is_same<remove_cv_t<_Tp1>, path>>,
-                             __not_<is_void<_Tp1>>,
+                             __not_<is_void<remove_pointer_t<_Tp1>>>,
                              __constructible_from<_Tp1, _Tp2>>::value,
                       path>::type;
 
index f81f33ca1611b1a1156d2a3e14c8bfeaf21b33ef..588f06822beb60939a352cdb9f4d5dc41a25964d 100644 (file)
@@ -128,11 +128,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
       : decltype(__is_path_src(std::declval<_Source>(), 0))
       { };
 
-    template<typename _Tp1, typename _Tp2 = void>
+    template<typename _Tp1, typename _Tp2 = void,
+            typename _Tp1_nocv = typename remove_cv<_Tp1>::type,
+            typename _Tp1_noptr = typename remove_pointer<_Tp1>::type>
       using _Path = typename
-       std::enable_if<__and_<__not_<is_same<typename remove_cv<_Tp1>::type,
-                                            path>>,
-                             __not_<is_void<_Tp1>>,
+       std::enable_if<__and_<__not_<is_same<_Tp1_nocv, path>>,
+                             __not_<is_void<_Tp1_noptr>>,
                              __constructible_from<_Tp1, _Tp2>>::value,
                       path>::type;
 
index 71cdaa9d969236156a237f237742f3d0caeacba8..e22e3deb56e49ce37462fd7c417ab0111d8835f7 100644 (file)
 
 using std::filesystem::path;
 
+// PR libstdc++/80762.cc
 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&> );
+
+// PR libstdc++/90454.cc
+static_assert( !std::is_constructible_v<path, void*> );
+static_assert( !std::is_constructible_v<path, const void*> );
+static_assert( !std::is_constructible_v<path, volatile void*> );
+static_assert( !std::is_constructible_v<path, const volatile void*> );
+static_assert( !std::is_constructible_v<path, void*&> );
+static_assert( !std::is_constructible_v<path, void* const&> );
+static_assert( !std::is_constructible_v<path, const void* const&> );
index fa4a64feb3ef5f944234986a8b5a75f73de47453..98dadabcffba77bf25a1ead29e864579dd444b69 100644 (file)
 
 using std::experimental::filesystem::path;
 
+// PR libstdc++/80762.cc
 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, "" );
+
+// PR libstdc++/90454.cc
+static_assert( !std::is_constructible<path, void*>::value, "" );
+static_assert( !std::is_constructible<path, const void*>::value, "" );
+static_assert( !std::is_constructible<path, volatile void*>::value, "" );
+static_assert( !std::is_constructible<path, const volatile void*>::value, "" );
+static_assert( !std::is_constructible<path, void*&>::value, "" );
+static_assert( !std::is_constructible<path, void* const&>::value, "" );
+static_assert( !std::is_constructible<path, const void* const&>::value, "" );