Bug in Compiler? Constexpr doesn't have constant value

Bug in Compiler? Constexpr doesn't have constant value


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() {

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,


Descargar intelconstexprtest.cpp332 bytes
publicaciones de 2 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

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.


Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya