Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

method constexpr bug with c++ compiler 15

$
0
0

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)

AdjuntoTamaño
Descargarmain.cpp389 bytes

Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>