diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2021-05-17 11:54:06 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2021-05-17 17:58:46 +0100 |
commit | 45aa7a447652e8541cc381d7ab128544f81ed857 (patch) | |
tree | 8d853ef6ec0d7bf62d59190885f81b87f2e917d1 /libstdc++-v3/testsuite/27_io/filesystem | |
parent | fd89fc77639a63a141dbbc6292dd73e653794d61 (diff) |
libstdc++: Fix filesystem::path constraints for volatile [PR 100630]
The constraint check for filesystem::path construction uses
decltype(__is_path_src(declval<Source>())) which mean it considers
conversion from an rvalue. When Source is a volatile-qualified type
it cannot use is_path_src(const Unknown&) because a const lvalue
reference can only bind to a non-volatile rvalue.
Since the relevant path members all have a const Source& parameter,
the constraint should be defined in terms of declval<const Source&>(),
not declval<Source>(). This avoids the problem of volatile-qualified
rvalues, because we no longer use an rvalue at all.
libstdc++-v3/ChangeLog:
PR libstdc++/100630
* include/experimental/bits/fs_path.h (__is_constructible_from):
Test construction from a const lvalue, not an rvalue.
* testsuite/27_io/filesystem/path/construct/100630.cc: New test.
* testsuite/experimental/filesystem/path/construct/100630.cc:
New test.
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/filesystem')
-rw-r--r-- | libstdc++-v3/testsuite/27_io/filesystem/path/construct/100630.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/construct/100630.cc b/libstdc++-v3/testsuite/27_io/filesystem/path/construct/100630.cc new file mode 100644 index 00000000000..eb8473e600e --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/filesystem/path/construct/100630.cc @@ -0,0 +1,14 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include <filesystem> + +void f(bool) { } +void f(const std::filesystem::path&) { } + +void +test_100630() +{ + volatile bool b = true; + f(b); +} |