- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following code does not compile with ICC (versions below) but does with GCC was already posted on StackOverflow
class Constants { static constexpr int value_ = 2; public: static constexpr inline int V() { return value_; } }; typedef Constants CC; template<int N> class Terror { public: template<class T> void F(T (&a)[CC::V()]) {} }; int main() { int array[CC::V()]; Terror<42> ter = Terror<42>(); ter.F(array); }
Tested with:
Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.4.258 Build 20160811 Copyright (C) 1985-2016 Intel Corporation. All rights reserved.
and
Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 18.0.0.128 Build 20170811 Copyright (C) 1985-2017 Intel Corporation. All rights reserved.
- Tags:
- CC++
- Development Tools
- Intel® C++ Compiler
- Intel® Parallel Studio XE
- Intel® System Studio
- Optimization
- Parallel Computing
- Vectorization
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wasn't there a post recently indicating when constexpr implementation should be expected in icc? Apparently, 16.0 had partial implementation but a full one hasn't released yet.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Okay, I must have missed that. I saw some other constexpr/template issues have been addressed. But since I tried Intel 18.0. I was a little disappointed ;)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I assume you are seeing the diagnostic below. This does look like a compiler bug. I have filed a bug report in our internal bugs database with ID cmplrs-46576. The problem is still present in our development compiler. Thanks for reporting it and creating a nice small example for us.
Judy
//bug.cpp constexpr int V() { return 2; } template<class T> #ifdef OK void F(T (&a)[2]) {} #else void F(T (&a)[V()]) {} #endif int main() { int array[2]; F(array); return 0; } sptel42-1185> g++ -c bug.cpp sptel42-1186> icpc -c bug.cpp bug.cpp(13): error: no instance of function template "F" matches the argument list argument types are: (int [2])
F(array); ^ bug.cpp(8): note: this candidate was rejected because at least one template argument could not be deduced void F(T (&a)[V()]) {} ^ compilation aborted for bug.cpp (code 2)

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page