Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
7679 Discussions

method constexpr bug with c++ compiler 15

rnickb
Beginner
190 Views
icc give an error when using a constexpr function in the context of a method function template, though the same function is correctly recognized as a constexpr in other contexts. I appended an example below. The code compiles fine with g++ and clang++ and this looks distinct from the other constexpr bug I submitted yesterday. #include template struct MySequence {}; template constexpr int getconst(const MySequence& arg) { return 1; } struct A { template void f() { } }; using MySeq = MySequence; int main() { std::array an_array; //this works fine A a; a.f(); //fails return 0; } The error given is: icc -std=c++11 -I ~/proj/echo/k_array/include/ main.cpp main.cpp(23): error: expression must have a constant value a.f(); //fails ^ main.cpp(23): error: no instance of function template "getconst" matches the argument list argument types are: () a.f(); //fails ^ main.cpp(23): error: no instance of function template "A::f" matches the argument list object type is: A a.f(); //fails ^ compilation aborted for main.cpp (code 2)
0 Kudos
2 Replies
Shenghong_G_Intel
190 Views

Hi rnickb,

Thank you for the test case, I can reproduce it with latest ICC compiler. I will submit it to dev team to fix.

Thanks,

Shenghong

Shenghong_G_Intel
190 Views

Hi rnickb,

FYI. This issue is fixed in 2015 U3 release and 2016 beta. See below of my verification:

$ source /opt/intel/composer_xe_2015.2.164/bin/compilervars.sh intel64
$ icc temp.cpp -std=c++11
temp.cpp(23): error: expression must have a constant value
    a.f<getconst(MySeq())>(); //fails
                 ^

temp.cpp(23): error: no instance of function template "getconst" matches the argument list
            argument types are: (<error-type>)
    a.f<getconst(MySeq())>(); //fails
        ^

temp.cpp(23): error: no instance of function template "A::f" matches the argument list
            object type is: A
    a.f<getconst(MySeq())>(); //fails
      ^

compilation aborted for temp.cpp (code 2)
$ source /opt/intel/composer_xe_2015.3.187/bin/compilervars.sh intel64
$ icc temp.cpp -std=c++11
$ ./a.out
$

Thanks,

Shenghong

Reply