Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

Bug in Compiler? Constexpr doesn't have constant value

Raffael_C_
Beginner
297 Views

Hi,

I just came across a rather weird behaviour of the Intel C++ Composer XE2013, SP1 on Windows. I managed to reduce it to the following simple test program:

[cpp]

template<int A>

constexpr int foo(int b) {   return A==b ? A : 0; }

template<int A> std::array<int,foo<1>(A)> bar() {  

 std::cout << "hello" << std::endl;

}

int main() {

bar<1>();

}

[/cpp]

When I want to compile this on windows I get the following error message: "error : function call must have a constant value in a constant expression". However I believe that the code is correct, at least I was able to compile it on linux with clang 3.3 and g++ 4.8.1 without any problems.

Is my code actually c++11 conform or is it a bug in the Intel compiler?

For completeness I have attached the above source code to this message...

Thanks in advance,

Raffael

0 Kudos
1 Reply
Judith_W_Intel
Employee
297 Views

Yes indeed this does appear to be a bug in our compiler in non GNU compatibility modes.

I have entered this into our internal bug tracking database as DPD200248495. Thanks for bringing it to our attention.

Judy

0 Kudos
Reply