[Bug libstdc++/117560] std::views::zip incompatible with std::filesystem::directory_iterator & std::views::transform

2024-11-13 Thread ralph.ursprung at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117560

--- Comment #1 from Ralph Ursprung  ---
Created attachment 59589
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59589&action=edit
test case which compiles fine (using views::single, not filesystem)

[Bug libstdc++/117560] std::views::zip incompatible with std::filesystem::directory_iterator & std::views::transform

2024-11-13 Thread ralph.ursprung at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117560

--- Comment #2 from Ralph Ursprung  ---
Created attachment 59590
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59590&action=edit
test case which compiles fine (without views::transform)

[Bug libstdc++/117560] New: std::views::zip incompatible with std::filesystem::directory_iterator & std::views::transform

2024-11-13 Thread ralph.ursprung at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117560

Bug ID: 117560
   Summary: std::views::zip incompatible with
std::filesystem::directory_iterator &
std::views::transform
   Product: gcc
   Version: 14.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ralph.ursprung at gmail dot com
  Target Milestone: ---

Created attachment 59588
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59588&action=edit
test case reproducing the error

the attached code compiles fine with MSVC (tested on Windows 11 x64 with
17.12.0 but also worked before with previous 17.11.x and possibly older
releases) and LLVMs libc++ (tested on Ubuntu 24.04 LTS with 18.1.3) but fails
with GCCs libstdc++ (tested with GCC/libstdc++ 14.2.0).

this is a problem in the standard library implementation and not the compiler
as clang fails with the same compile error as GCC when using libstdc++ but
works fine when using its own library.
i have narrowed it down to the combination of
`std::filesystem::directory_iterator`, `std::views::transform` and
`std::views::zip` (though others might of course be affected! i just reduced my
real-world problem to this test-case).

you can get the code to compile by removing the `| std::views::transform(t)`
from the two variables `x1` & `x2` in the test case or by replacing
`std::filesystem::directory_iterator{p}` with `std::views::empty`
(or something similarly simple, e.g.
`std::views::single(std::string{"hello"})`).

error using GCC:
> $ g++-14 -std=c++23 -Wall -Wextra filesystem-fail.cpp && ./a.out
> filesystem-fail.cpp: In function ‘int main()’:
> filesystem-fail.cpp:15:46: error: no match for call to ‘(const 
> std::ranges::views::_Zip) 
> (std::ranges::transform_view,
>  main():: >&, 
> std::ranges::transform_view,
>  main():: >&)’
>15 |   for (auto const& [f1, f2] : std::views::zip(x1, x2)) {
>   |   ~~~^~~~
> In file included from filesystem-fail.cpp:3:
> /usr/include/c++/14/ranges:4969:9: note: candidate: ‘template  
> requires  sizeof ... (_Ts ...) == 0 || (__can_zip_view<_Ts ...>) constexpr 
> auto std::ranges::views::_Zip::operator()(_Ts&& ...) const’
>  4969 | operator() [[nodiscard]] (_Ts&&... __ts) const
>   | ^~~~
> /usr/include/c++/14/ranges:4969:9: note:   template argument 
> deduction/substitution failed:
> /usr/include/c++/14/ranges:4969:9: note: constraints not satisfied
> filesystem-fail.cpp: In substitution of ‘template  requires  
> sizeof ... (_Ts ...) == 0 || (__can_zip_view<_Ts ...>) constexpr auto 
> std::ranges::views::_Zip::operator()(_Ts&& ...) const [with _Ts = 
> {std::ranges::transform_view,
>  main():: >&, 
> std::ranges::transform_view,
>  main():: >&}]’:
> filesystem-fail.cpp:15:46:   required from here
>15 |   for (auto const& [f1, f2] : std::views::zip(x1, x2)) {
>   |   ~~~^~~~
> /usr/include/c++/14/ranges:4969:2:   required by the constraints of 
> ‘template  requires  sizeof ... (_Ts ...) == 0 || 
> (__can_zip_view<_Ts ...>) constexpr auto 
> std::ranges::views::_Zip::operator()(_Ts&& ...) const’
> /usr/include/c++/14/ranges:4967:39: note: no operand of the disjunction is 
> satisfied
>  4967 | requires (sizeof...(_Ts) == 0 || 
> __detail::__can_zip_view<_Ts...>)
>   |  
> ~^~~~
> cc1plus: note: set ‘-fconcepts-diagnostics-depth=’ to at least 2 for more 
> detail

GCC version:
> $ g++-14 -v
> Using built-in specs.
> COLLECT_GCC=g++-14
> COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/14/lto-wrapper
> OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
> OFFLOAD_TARGET_DEFAULT=1
> Target: x86_64-linux-gnu
> Configured with: ../src/configure -v --with-pkgversion='Ubuntu 
> 14.2.0-4ubuntu2~24.04' --with-bugurl=file:///usr/share/doc/gcc-14/README.Bugs 
> --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2,rust --prefix=/usr 
> --with-gcc-major-version-only --program-suffix=-14 
> --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id 
> --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix 
> --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu 
> --enable-libstdcxx-debug --enable-libstdcxx-time=yes 
> --with-default-libstdcxx-abi=new --enable-libstdcxx-backtrace 
> --enable-gnu-unique-object --disable-vtable-verify --enable-plugin 
> --enable-default-pie --with-system-zlib --enable-libphobos-checking=release 
> --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch 
> --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 
> --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic 
> --enable-offload-targets=nvptx-none=/build/gcc-14-ig5ci0/gcc-14-14.2