[Bug libstdc++/100630] Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jun 18 14:43:46 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100630

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:3c805829c9023da48db6d636221fd79612dff7ea

commit r9-9593-g3c805829c9023da48db6d636221fd79612dff7ea
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon May 17 11:54:06 2021 +0100

    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/bits/fs_path.h (__is_constructible_from): Test
            construction from a const lvalue, not an rvalue.
            * include/experimental/bits/fs_path.h (__is_constructible_from):
            Likewise.
            * testsuite/27_io/filesystem/path/construct/100630.cc: New test.
            * testsuite/experimental/filesystem/path/construct/100630.cc:
            New test.

    (cherry picked from commit 4cd69a5a0dd31bc6fdef1bbabc8d6d1416014ea1)


More information about the Gcc-bugs mailing list