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

compiler fails on enum assignment

Walter_D_
Beginner
358 Views

icpc version 13.1.3 cannot compile this simple code

[cpp]

enum which { none=0, some=1, all=2 };


template<bool X, bool Y>
struct foo
{
  static const which R = X? which::all : which::some;
  static const which L = Y? R : which::none;
};


template struct foo<1,0>;
[/cpp]

but complains with the error message

[plain]

test.cc(8): error: a value of type "int" cannot be used to initialize an entity of type "const which"
    static const which L = Y? R : which::none;
                           ^
          detected during instantiation of class "foo<X, Y> [with X=true, Y=false]" at line 8
[/plain]

Note that both gcc (4.8.1) and clang++ have no issues with this code.

0 Kudos
2 Replies
Judith_W_Intel
Employee
358 Views

 

Please update to the latest version of our compiler (14.0) where this problem is fixed. 13.1 is no longer being updated.

thanks

Judy

0 Kudos
Walter_D_
Beginner
358 Views

thanks. Yes, I noted that myself (after posting this and after my admin installed 14.0.1). However there are other (minor so far) issues with 14.0.1 ... I will open another thread for that.

0 Kudos
Reply