Bug in Compiler? Constexpr doesn't have constant value

Bug in Compiler? Constexpr doesn't have constant value

Ritratto di Raffael C.

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:

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>();
}

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

AllegatoDimensione
Scarica intelconstexprtest.cpp332 byte
2 post / 0 new
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione
Ritratto di Judith Ward (Intel)

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

Accedere per lasciare un commento.