Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*

icpx `std::views::zip` compile error

PeterFačko
Beginner
2,416 Views

Hello, when compiling this source code:

#include <algorithm>
#include <execution>
#include <ranges>
#include <utility>
#include <vector>

int main(int argc, char** argv)
{
    const auto input = std::vector<int>(100);

    auto output_a = std::vector<int>(input.size());
    auto output_b = std::vector<int>(input.size());

    auto zipped = std::views::zip(output_a, output_b);

    std::transform(std::execution::par_unseq,
                   input.begin(),
                   input.end(),
                   zipped.begin(),
                   [](auto) -> std::pair<int, int>
                   {
                       return {};
                   });

    return 0;
}

with:

icpx -std=c++23 -qtbb test.cpp -o test

I get:

In file included from test.cpp:3:
/usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/ranges:4558:14: error: type constraint differs in template redeclaration
 4558 |     template<copy_constructible _Fp, input_range... _Ws>
      |              ^
/usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/ranges:4458:14: note: in instantiation of template class 'std::ranges::zip_view<std::ranges::ref_view<std::vector<int>>, std::ranges::ref_view<std::vector<int>>>::_Iterator<true>' requested here
 4458 |     { return _Iterator<true>(__detail::__tuple_transform(ranges::begin, _M_views)); }
      |              ^
test.cpp:19:27: note: in instantiation of member function 'std::ranges::zip_view<std::ranges::ref_view<std::vector<int>>, std::ranges::ref_view<std::vector<int>>>::begin' requested here
   19 |                    zipped.begin(),
      |                           ^
/usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/ranges:4829:12: note: previous template declaration is here
 4829 |   template<copy_constructible _Fp, input_range... _Vs>
      |            ^
/usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/ranges:4558:14: error: type constraint differs in template redeclaration
 4558 |     template<copy_constructible _Fp, input_range... _Ws>
      |              ^
/usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/ranges:4458:30: note: in instantiation of template class 'std::ranges::zip_view<std::ranges::ref_view<std::vector<int>>, std::ranges::ref_view<std::vector<int>>>::_Iterator<false>' requested here
 4458 |     { return _Iterator<true>(__detail::__tuple_transform(ranges::begin, _M_views)); }
      |                              ^
test.cpp:19:27: note: in instantiation of member function 'std::ranges::zip_view<std::ranges::ref_view<std::vector<int>>, std::ranges::ref_view<std::vector<int>>>::begin' requested here
   19 |                    zipped.begin(),
      |                           ^
/usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/ranges:4829:12: note: previous template declaration is here
 4829 |   template<copy_constructible _Fp, input_range... _Vs>
      |            ^
2 errors generated.

 When compiling with:

g++ -std=c++23 -ltbb test.cpp -o test

the compilation is successful.

 

[fackop@PPpc-main PPtrading]$ g++ --version
g++ (GCC) 13.2.1 20230801
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[fackop@PPpc-main PPtrading]$ icpx --version
Intel(R) oneAPI DPC++/C++ Compiler 2024.0.2 (2024.0.2.20231213)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/intel/oneapi/compiler/2024.0/bin/compiler
Configuration file: /opt/intel/oneapi/compiler/2024.0/bin/compiler/../icpx.cfg

 

Is this a bug? Thank you in advance for any help.

 

Peter Fačko

0 Kudos
1 Solution
mayurp
Moderator
2,274 Views

To get this to work we need newer library that has this change: https://github.com/gcc-mirror/gcc/commit/be34a8b538c0f04b11a428bd1a9340eb19dec13f


With that library change applied to a preprocessed version of the test case, icpx compiles it okay.


cp /path-of-ranges-file myinclude

cd myinclude

patch ranges be34a8b538c0f04b11a428bd1a9340eb19dec13f.diff  (patch link - https://github.com/gcc-mirror/gcc/commit/be34a8b538c0f04b11a428bd1a9340eb19dec13f.diff )


icpx -Imyinclude -std=c++23 test.cpp  -- compiles fine



View solution in original post

7 Replies
Vipin_S_Intel
Moderator
2,385 Views

Hi Peter, we would like to inform you that we are routing your query to the dedicated team for further assistance.

 

Thanks!


PeterFačko
Beginner
2,332 Views
0 Kudos
mayurp
Moderator
2,327 Views

Hi Peter, we have been able to reproduce the issue and have raised it with the developer team.


0 Kudos
mayurp
Moderator
2,275 Views

To get this to work we need newer library that has this change: https://github.com/gcc-mirror/gcc/commit/be34a8b538c0f04b11a428bd1a9340eb19dec13f


With that library change applied to a preprocessed version of the test case, icpx compiles it okay.


cp /path-of-ranges-file myinclude

cd myinclude

patch ranges be34a8b538c0f04b11a428bd1a9340eb19dec13f.diff  (patch link - https://github.com/gcc-mirror/gcc/commit/be34a8b538c0f04b11a428bd1a9340eb19dec13f.diff )


icpx -Imyinclude -std=c++23 test.cpp  -- compiles fine



arctic_circle
Beginner
2,161 Views

Dear Mayurp,

 

I am sorry for posting off topic but I am unable to post any questions in the forum. When I try to post a question I get this error: 

 

"An Unexpected Error has occurred.
Your request failed. Please contact your system administrator and provide the date and time you received the error and this Exception ID: 558D0528."

 

Can you please let me know how to fix this and post questions? I would like to post a question about compiling DLLs with oneAPI (specifically, how to ensure that function names are exported properly - sqrt() and some other math functions seem to be interfering with exporting functions) but I can't post questions. Thank you

0 Kudos
mayurp
Moderator
2,055 Views

I will ask the relevant team to look into this.


0 Kudos
mayurp
Moderator
2,055 Views

This issue has been resolved and we will no longer respond to this thread. If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.


0 Kudos
Reply