Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Ludwig_Jens_P_
Beginner
56 Views

Generating and modifing constexpr tuples

Intel compiler: icpc (ICC) 17.0.2 20170213
g++: g++ (GCC) 5.4.0
clang++: clang version 3.5.2

The following code compiles with g++ and clang++ but not with the intel compiler (using -std=c++14):

using tuple_type = decltype(std::make_tuple(3));

constexpr tuple_type const_tuple0(std::make_tuple(3));
constexpr tuple_type const_tuple1 {std::make_tuple(3)};
constexpr tuple_type const_tuple2 = std::make_tuple(3);

With c++14 we have the possibility to generate and modify compile-time tuples. Unfortunately the intel compiler doesn't seem to like this and complains with

error: expression must have a constant value

for all three statements. Further investigation showed that any constexpr function returning a tuple won't compile. Returning user-defined constexpr classes from constexpr functions works. So there seems to be a problem in returning constexpr tuples.

0 Kudos
2 Replies
Judith_W_Intel
Employee
56 Views

 

I can reproduce the errors with 17.0 but it compiles cleanly with 18.0 (currently in beta). Would you be able to use that instead?

Ludwig_Jens_P_
Beginner
56 Views

No that's not a viable option (yet), since we need this in production code. But good to know that it is at least already fixed in 18.0. At the moment we are converting all the tuple logic to compile-time integer arithmetic.