public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/100630] New: Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10
@ 2021-05-17 0:13 romain.geissler at amadeus dot com
2021-05-17 9:18 ` [Bug libstdc++/100630] " redi at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: romain.geissler at amadeus dot com @ 2021-05-17 0:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100630
Bug ID: 100630
Summary: Unexpected implicit conversion from volatile bool& to
std::filesystem::path in gcc <= 10
Product: gcc
Version: 10.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: romain.geissler at amadeus dot com
Target Milestone: ---
Hi,
I came across this issue today (which I think is unexpected) with gcc 8, 9 and
10. It seems that the following code triggers some implicit conversion from
volatile bool& to std::filesystem::path while this was definitely not the
intention:
#include <filesystem>
#include <iostream>
class Printer
{
public:
Printer& operator<<(bool iValue)
{
std::cout << __PRETTY_FUNCTION__<< ": " << std::boolalpha << iValue
<< std::endl;
return *this;
};
Printer& operator<<(const std::filesystem::path& iPath)
{
std::cout << __PRETTY_FUNCTION__<< ": " << std::boolalpha << iPath
<< std::endl;
return *this;
};
};
int main()
{
Printer aPrinter;
volatile bool a = false;
aPrinter << a;
};
It raises the following error (for example using gcc 10 in Compiler Explorer):
In file included from
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/filesystem:45,
from <source>:1:
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h: In
instantiation of 'struct
std::filesystem::__cxx11::__detail::__constructible_from<volatile bool, void>':
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/type_traits:138:12:
required from 'struct std::__and_<std::__not_<std::is_void<volatile bool> >,
std::filesystem::__cxx11::__detail::__constructible_from<volatile bool, void>
>'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/type_traits:143:12:
required from 'struct std::__and_<std::__not_<std::is_same<bool,
std::filesystem::__cxx11::path> >, std::__not_<std::is_void<volatile bool> >,
std::filesystem::__cxx11::__detail::__constructible_from<volatile bool, void>
>'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:123:11:
required by substitution of 'template<class _Tp1, class _Tp2> using _Path =
typename std::enable_if<std::__and_<std::__not_<std::is_same<typename
std::remove_cv< <template-parameter-1-1> >::type,
std::filesystem::__cxx11::path> >, std::__not_<std::is_void<typename
std::remove_pointer<_Tp>::type> >,
std::filesystem::__cxx11::__detail::__constructible_from<_Tp1, _Tp2> >::value,
std::filesystem::__cxx11::path>::type [with _Tp1 = volatile bool; _Tp2 = void]'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:223:7:
required by substitution of 'template<class _Source, class _Require>
std::filesystem::__cxx11::path::path(const _Source&,
std::filesystem::__cxx11::path::format) [with _Source = volatile bool; _Require
= <missing>]'
<source>:27:17: required from here
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:119:29:
error: no matching function for call to '__is_path_src(volatile bool, int)'
119 | : decltype(__is_path_src(std::declval<_Source>(), 0))
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:95:5: note:
candidate: 'template<class _Iter>
std::filesystem::__cxx11::__detail::__is_path_iter_src<_Iter>
std::filesystem::__cxx11::__detail::__is_path_src(_Iter, int)'
95 | __is_path_src(_Iter, int);
| ^~~~~~~~~~~~~
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:95:5: note:
template argument deduction/substitution failed:
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h: In
substitution of 'template<class _Iter, class _Iter_traits> using
__is_path_iter_src = std::__and_<std::__or_<std::is_same<typename
std::remove_const<typename _Iter_traits::value_type>::type, char>,
std::is_same<typename std::remove_const<typename
_Iter_traits::value_type>::type, wchar_t>, std::is_same<typename
std::remove_const<typename _Iter_traits::value_type>::type, char16_t>,
std::is_same<typename std::remove_const<typename
_Iter_traits::value_type>::type, char32_t> >,
std::is_base_of<std::input_iterator_tag, typename
_Iter_traits::iterator_category> > [with _Iter = bool; _Iter_traits =
std::iterator_traits<bool>]':
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:95:5:
required by substitution of 'template<class _Iter>
std::filesystem::__cxx11::__detail::__is_path_iter_src<_Iter>
std::filesystem::__cxx11::__detail::__is_path_src(_Iter, int) [with _Iter =
bool]'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:119:29:
required from 'struct
std::filesystem::__cxx11::__detail::__constructible_from<volatile bool, void>'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/type_traits:138:12:
required from 'struct std::__and_<std::__not_<std::is_void<volatile bool> >,
std::filesystem::__cxx11::__detail::__constructible_from<volatile bool, void>
>'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/type_traits:143:12:
required from 'struct std::__and_<std::__not_<std::is_same<bool,
std::filesystem::__cxx11::path> >, std::__not_<std::is_void<volatile bool> >,
std::filesystem::__cxx11::__detail::__constructible_from<volatile bool, void>
>'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:123:11:
required by substitution of 'template<class _Tp1, class _Tp2> using _Path =
typename std::enable_if<std::__and_<std::__not_<std::is_same<typename
std::remove_cv< <template-parameter-1-1> >::type,
std::filesystem::__cxx11::path> >, std::__not_<std::is_void<typename
std::remove_pointer<_Tp>::type> >,
std::filesystem::__cxx11::__detail::__constructible_from<_Tp1, _Tp2> >::value,
std::filesystem::__cxx11::path>::type [with _Tp1 = volatile bool; _Tp2 = void]'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:223:7:
required by substitution of 'template<class _Source, class _Require>
std::filesystem::__cxx11::path::path(const _Source&,
std::filesystem::__cxx11::path::format) [with _Source = volatile bool; _Require
= <missing>]'
<source>:27:17: required from here
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:88:11:
error: no type named 'value_type' in 'struct std::iterator_traits<bool>'
88 | using __is_path_iter_src
| ^~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h: In
instantiation of 'struct
std::filesystem::__cxx11::__detail::__constructible_from<volatile bool, void>':
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/type_traits:138:12:
required from 'struct std::__and_<std::__not_<std::is_void<volatile bool> >,
std::filesystem::__cxx11::__detail::__constructible_from<volatile bool, void>
>'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/type_traits:143:12:
required from 'struct std::__and_<std::__not_<std::is_same<bool,
std::filesystem::__cxx11::path> >, std::__not_<std::is_void<volatile bool> >,
std::filesystem::__cxx11::__detail::__constructible_from<volatile bool, void>
>'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:123:11:
required by substitution of 'template<class _Tp1, class _Tp2> using _Path =
typename std::enable_if<std::__and_<std::__not_<std::is_same<typename
std::remove_cv< <template-parameter-1-1> >::type,
std::filesystem::__cxx11::path> >, std::__not_<std::is_void<typename
std::remove_pointer<_Tp>::type> >,
std::filesystem::__cxx11::__detail::__constructible_from<_Tp1, _Tp2> >::value,
std::filesystem::__cxx11::path>::type [with _Tp1 = volatile bool; _Tp2 = void]'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:223:7:
required by substitution of 'template<class _Source, class _Require>
std::filesystem::__cxx11::path::path(const _Source&,
std::filesystem::__cxx11::path::format) [with _Source = volatile bool; _Require
= <missing>]'
<source>:27:17: required from here
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:99:5: note:
candidate: 'template<class _CharT, class _Traits, class _Alloc>
std::filesystem::__cxx11::__detail::__is_encoded_char<_CharT>
std::filesystem::__cxx11::__detail::__is_path_src(const
std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&, int)'
99 | __is_path_src(const basic_string<_CharT, _Traits, _Alloc>&, int);
| ^~~~~~~~~~~~~
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:99:5: note:
template argument deduction/substitution failed:
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:119:29:
note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits,
_Allocator>' and 'volatile bool'
119 | : decltype(__is_path_src(std::declval<_Source>(), 0))
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:103:5:
note: candidate: 'template<class _CharT, class _Traits>
std::filesystem::__cxx11::__detail::__is_encoded_char<_CharT>
std::filesystem::__cxx11::__detail::__is_path_src(const
std::basic_string_view<_CharT, _Traits>&, int)'
103 | __is_path_src(const basic_string_view<_CharT, _Traits>&, int);
| ^~~~~~~~~~~~~
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:103:5:
note: template argument deduction/substitution failed:
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:119:29:
note: mismatched types 'const std::basic_string_view<_CharT, _Traits>' and
'volatile bool'
119 | : decltype(__is_path_src(std::declval<_Source>(), 0))
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:107:5:
note: candidate: 'std::false_type
std::filesystem::__cxx11::__detail::__is_path_src(const _Unknown&, ...) [with
_Unknown = volatile bool; std::false_type = std::integral_constant<bool,
false>]' (near match)
107 | __is_path_src(const _Unknown&, ...);
| ^~~~~~~~~~~~~
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:107:5:
note: conversion of argument 1 would be ill-formed:
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:119:29:
error: cannot bind non-const lvalue reference of type 'const volatile bool&' to
an rvalue of type 'volatile bool'
119 | : decltype(__is_path_src(std::declval<_Source>(), 0))
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ASM generation compiler returned: 1
In file included from
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/filesystem:45,
from <source>:1:
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h: In
instantiation of 'struct
std::filesystem::__cxx11::__detail::__constructible_from<volatile bool, void>':
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/type_traits:138:12:
required from 'struct std::__and_<std::__not_<std::is_void<volatile bool> >,
std::filesystem::__cxx11::__detail::__constructible_from<volatile bool, void>
>'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/type_traits:143:12:
required from 'struct std::__and_<std::__not_<std::is_same<bool,
std::filesystem::__cxx11::path> >, std::__not_<std::is_void<volatile bool> >,
std::filesystem::__cxx11::__detail::__constructible_from<volatile bool, void>
>'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:123:11:
required by substitution of 'template<class _Tp1, class _Tp2> using _Path =
typename std::enable_if<std::__and_<std::__not_<std::is_same<typename
std::remove_cv< <template-parameter-1-1> >::type,
std::filesystem::__cxx11::path> >, std::__not_<std::is_void<typename
std::remove_pointer<_Tp>::type> >,
std::filesystem::__cxx11::__detail::__constructible_from<_Tp1, _Tp2> >::value,
std::filesystem::__cxx11::path>::type [with _Tp1 = volatile bool; _Tp2 = void]'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:223:7:
required by substitution of 'template<class _Source, class _Require>
std::filesystem::__cxx11::path::path(const _Source&,
std::filesystem::__cxx11::path::format) [with _Source = volatile bool; _Require
= <missing>]'
<source>:27:17: required from here
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:119:29:
error: no matching function for call to '__is_path_src(volatile bool, int)'
119 | : decltype(__is_path_src(std::declval<_Source>(), 0))
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:95:5: note:
candidate: 'template<class _Iter>
std::filesystem::__cxx11::__detail::__is_path_iter_src<_Iter>
std::filesystem::__cxx11::__detail::__is_path_src(_Iter, int)'
95 | __is_path_src(_Iter, int);
| ^~~~~~~~~~~~~
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:95:5: note:
template argument deduction/substitution failed:
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h: In
substitution of 'template<class _Iter, class _Iter_traits> using
__is_path_iter_src = std::__and_<std::__or_<std::is_same<typename
std::remove_const<typename _Iter_traits::value_type>::type, char>,
std::is_same<typename std::remove_const<typename
_Iter_traits::value_type>::type, wchar_t>, std::is_same<typename
std::remove_const<typename _Iter_traits::value_type>::type, char16_t>,
std::is_same<typename std::remove_const<typename
_Iter_traits::value_type>::type, char32_t> >,
std::is_base_of<std::input_iterator_tag, typename
_Iter_traits::iterator_category> > [with _Iter = bool; _Iter_traits =
std::iterator_traits<bool>]':
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:95:5:
required by substitution of 'template<class _Iter>
std::filesystem::__cxx11::__detail::__is_path_iter_src<_Iter>
std::filesystem::__cxx11::__detail::__is_path_src(_Iter, int) [with _Iter =
bool]'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:119:29:
required from 'struct
std::filesystem::__cxx11::__detail::__constructible_from<volatile bool, void>'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/type_traits:138:12:
required from 'struct std::__and_<std::__not_<std::is_void<volatile bool> >,
std::filesystem::__cxx11::__detail::__constructible_from<volatile bool, void>
>'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/type_traits:143:12:
required from 'struct std::__and_<std::__not_<std::is_same<bool,
std::filesystem::__cxx11::path> >, std::__not_<std::is_void<volatile bool> >,
std::filesystem::__cxx11::__detail::__constructible_from<volatile bool, void>
>'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:123:11:
required by substitution of 'template<class _Tp1, class _Tp2> using _Path =
typename std::enable_if<std::__and_<std::__not_<std::is_same<typename
std::remove_cv< <template-parameter-1-1> >::type,
std::filesystem::__cxx11::path> >, std::__not_<std::is_void<typename
std::remove_pointer<_Tp>::type> >,
std::filesystem::__cxx11::__detail::__constructible_from<_Tp1, _Tp2> >::value,
std::filesystem::__cxx11::path>::type [with _Tp1 = volatile bool; _Tp2 = void]'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:223:7:
required by substitution of 'template<class _Source, class _Require>
std::filesystem::__cxx11::path::path(const _Source&,
std::filesystem::__cxx11::path::format) [with _Source = volatile bool; _Require
= <missing>]'
<source>:27:17: required from here
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:88:11:
error: no type named 'value_type' in 'struct std::iterator_traits<bool>'
88 | using __is_path_iter_src
| ^~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h: In
instantiation of 'struct
std::filesystem::__cxx11::__detail::__constructible_from<volatile bool, void>':
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/type_traits:138:12:
required from 'struct std::__and_<std::__not_<std::is_void<volatile bool> >,
std::filesystem::__cxx11::__detail::__constructible_from<volatile bool, void>
>'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/type_traits:143:12:
required from 'struct std::__and_<std::__not_<std::is_same<bool,
std::filesystem::__cxx11::path> >, std::__not_<std::is_void<volatile bool> >,
std::filesystem::__cxx11::__detail::__constructible_from<volatile bool, void>
>'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:123:11:
required by substitution of 'template<class _Tp1, class _Tp2> using _Path =
typename std::enable_if<std::__and_<std::__not_<std::is_same<typename
std::remove_cv< <template-parameter-1-1> >::type,
std::filesystem::__cxx11::path> >, std::__not_<std::is_void<typename
std::remove_pointer<_Tp>::type> >,
std::filesystem::__cxx11::__detail::__constructible_from<_Tp1, _Tp2> >::value,
std::filesystem::__cxx11::path>::type [with _Tp1 = volatile bool; _Tp2 = void]'
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:223:7:
required by substitution of 'template<class _Source, class _Require>
std::filesystem::__cxx11::path::path(const _Source&,
std::filesystem::__cxx11::path::format) [with _Source = volatile bool; _Require
= <missing>]'
<source>:27:17: required from here
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:99:5: note:
candidate: 'template<class _CharT, class _Traits, class _Alloc>
std::filesystem::__cxx11::__detail::__is_encoded_char<_CharT>
std::filesystem::__cxx11::__detail::__is_path_src(const
std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&, int)'
99 | __is_path_src(const basic_string<_CharT, _Traits, _Alloc>&, int);
| ^~~~~~~~~~~~~
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:99:5: note:
template argument deduction/substitution failed:
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:119:29:
note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits,
_Allocator>' and 'volatile bool'
119 | : decltype(__is_path_src(std::declval<_Source>(), 0))
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:103:5:
note: candidate: 'template<class _CharT, class _Traits>
std::filesystem::__cxx11::__detail::__is_encoded_char<_CharT>
std::filesystem::__cxx11::__detail::__is_path_src(const
std::basic_string_view<_CharT, _Traits>&, int)'
103 | __is_path_src(const basic_string_view<_CharT, _Traits>&, int);
| ^~~~~~~~~~~~~
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:103:5:
note: template argument deduction/substitution failed:
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:119:29:
note: mismatched types 'const std::basic_string_view<_CharT, _Traits>' and
'volatile bool'
119 | : decltype(__is_path_src(std::declval<_Source>(), 0))
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:107:5:
note: candidate: 'std::false_type
std::filesystem::__cxx11::__detail::__is_path_src(const _Unknown&, ...) [with
_Unknown = volatile bool; std::false_type = std::integral_constant<bool,
false>]' (near match)
107 | __is_path_src(const _Unknown&, ...);
| ^~~~~~~~~~~~~
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:107:5:
note: conversion of argument 1 would be ill-formed:
/opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/fs_path.h:119:29:
error: cannot bind non-const lvalue reference of type 'const volatile bool&' to
an rvalue of type 'volatile bool'
119 | : decltype(__is_path_src(std::declval<_Source>(), 0))
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Execution build compiler returned: 1
It seems that it works in gcc 11, and I guess this comes from this commit:
commit 988b853f9c829742907ae22ac66de56facfc7bc5
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Sat May 23 07:28:40 2020 +0100
libstdc++: Simplify filesystem::path SFINAE constraints
(which seems to have a few follow-up commits to fix some issues).
Shall these SFINAE changes be backported to gcc 9/10 (and I know that gcc 8 was
just closed, but in my case I would be interested by a gcc 8 backport too) ?
Cheers,
Romain
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/100630] Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10
2021-05-17 0:13 [Bug libstdc++/100630] New: Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10 romain.geissler at amadeus dot com
@ 2021-05-17 9:18 ` redi at gcc dot gnu.org
2021-05-17 14:01 ` cvs-commit at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2021-05-17 9:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100630
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-05-17
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Romain Geissler from comment #0)
> Hi,
>
> I came across this issue today (which I think is unexpected) with gcc 8, 9
> and 10. It seems that the following code triggers some implicit conversion
> from volatile bool& to std::filesystem::path while this was definitely not
> the intention:
It's not triggering such a conversion, it's checking if such a conversion is
viable as part of overload resolution. But then that instantiates something
that is ill-formed and fails with an error outside the immediate context.
I think the right fix for the branches is:
--- a/libstdc++-v3/include/bits/fs_path.h
+++ b/libstdc++-v3/include/bits/fs_path.h
@@ -116,7 +116,7 @@ namespace __detail
template<typename _Source>
struct __constructible_from<_Source, void>
- : decltype(__is_path_src(std::declval<_Source>(), 0))
+ : decltype(__is_path_src(std::declval<const _Source&>(), 0))
{ };
template<typename _Tp1, typename _Tp2 = void>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/100630] Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10
2021-05-17 0:13 [Bug libstdc++/100630] New: Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10 romain.geissler at amadeus dot com
2021-05-17 9:18 ` [Bug libstdc++/100630] " redi at gcc dot gnu.org
@ 2021-05-17 14:01 ` cvs-commit at gcc dot gnu.org
2021-05-17 17:11 ` cvs-commit at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-17 14:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100630
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:4cd69a5a0dd31bc6fdef1bbabc8d6d1416014ea1
commit r10-9831-g4cd69a5a0dd31bc6fdef1bbabc8d6d1416014ea1
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/100630] Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10
2021-05-17 0:13 [Bug libstdc++/100630] New: Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10 romain.geissler at amadeus dot com
2021-05-17 9:18 ` [Bug libstdc++/100630] " redi at gcc dot gnu.org
2021-05-17 14:01 ` cvs-commit at gcc dot gnu.org
@ 2021-05-17 17:11 ` cvs-commit at gcc dot gnu.org
2021-05-17 20:52 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-17 17:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100630
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:
https://gcc.gnu.org/g:45aa7a447652e8541cc381d7ab128544f81ed857
commit r12-845-g45aa7a447652e8541cc381d7ab128544f81ed857
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/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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/100630] Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10
2021-05-17 0:13 [Bug libstdc++/100630] New: Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10 romain.geissler at amadeus dot com
` (2 preceding siblings ...)
2021-05-17 17:11 ` cvs-commit at gcc dot gnu.org
@ 2021-05-17 20:52 ` cvs-commit at gcc dot gnu.org
2021-05-19 12:44 ` romain.geissler at amadeus dot com
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-17 20:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100630
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:f8d2cef5c544dd0196ec5a6f479fbf96d2214d76
commit r11-8425-gf8d2cef5c544dd0196ec5a6f479fbf96d2214d76
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/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.
(cherry picked from commit 45aa7a447652e8541cc381d7ab128544f81ed857)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/100630] Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10
2021-05-17 0:13 [Bug libstdc++/100630] New: Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10 romain.geissler at amadeus dot com
` (3 preceding siblings ...)
2021-05-17 20:52 ` cvs-commit at gcc dot gnu.org
@ 2021-05-19 12:44 ` romain.geissler at amadeus dot com
2021-05-19 14:04 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: romain.geissler at amadeus dot com @ 2021-05-19 12:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100630
--- Comment #5 from Romain Geissler <romain.geissler at amadeus dot com> ---
Hi,
Thanks for providing a fix that quickly !
I backported it in my own copy of gcc 8 and 9 and it fixed my issue on these
branches as well.
Cheers,
Romain
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/100630] Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10
2021-05-17 0:13 [Bug libstdc++/100630] New: Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10 romain.geissler at amadeus dot com
` (4 preceding siblings ...)
2021-05-19 12:44 ` romain.geissler at amadeus dot com
@ 2021-05-19 14:04 ` redi at gcc dot gnu.org
2021-06-18 14:43 ` cvs-commit at gcc dot gnu.org
2021-06-18 14:46 ` redi at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2021-05-19 14:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100630
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |9.5
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It's too late for 9.4 but I plan to backport it for 9.5
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/100630] Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10
2021-05-17 0:13 [Bug libstdc++/100630] New: Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10 romain.geissler at amadeus dot com
` (5 preceding siblings ...)
2021-05-19 14:04 ` redi at gcc dot gnu.org
@ 2021-06-18 14:43 ` cvs-commit at gcc dot gnu.org
2021-06-18 14:46 ` redi at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-18 14:43 UTC (permalink / raw)
To: gcc-bugs
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)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/100630] Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10
2021-05-17 0:13 [Bug libstdc++/100630] New: Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10 romain.geissler at amadeus dot com
` (6 preceding siblings ...)
2021-06-18 14:43 ` cvs-commit at gcc dot gnu.org
@ 2021-06-18 14:46 ` redi at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2021-06-18 14:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100630
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 9.5, 10.4 and 11.2
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-06-18 14:46 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 0:13 [Bug libstdc++/100630] New: Unexpected implicit conversion from volatile bool& to std::filesystem::path in gcc <= 10 romain.geissler at amadeus dot com
2021-05-17 9:18 ` [Bug libstdc++/100630] " redi at gcc dot gnu.org
2021-05-17 14:01 ` cvs-commit at gcc dot gnu.org
2021-05-17 17:11 ` cvs-commit at gcc dot gnu.org
2021-05-17 20:52 ` cvs-commit at gcc dot gnu.org
2021-05-19 12:44 ` romain.geissler at amadeus dot com
2021-05-19 14:04 ` redi at gcc dot gnu.org
2021-06-18 14:43 ` cvs-commit at gcc dot gnu.org
2021-06-18 14:46 ` redi at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).