- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page