- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a code example which originates from llvm source code but modified to clearly provide the issue.
It compiles fine with clang but fails with icl. Here's the code:
#include <type_traits>
template <typename E, typename Enable = void>
struct is_valid : std::false_type {};
template <typename E>
struct is_valid<E, typename std::enable_if<sizeof(E::EnumMember) >= 0>::type> : std::true_type {};
template <typename E, typename = typename std::enable_if<is_valid<E>::value>::type>
void function(const E &myEnum) {
return;
}
enum MyEnum {
EnumMember = 0
};
int main() {
MyEnum myEnum;
function(myEnum);
}
Intel Compiler XE 2018, Windows
- 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
Hi Ivan,
What kind of error are you seeing?
Thanks,
Viet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With this example:
icl_error_template.cpp(20): error: no instance of function template "function" matches the argument list
argument types are: (MyEnum)
function(myEnum);
^
icl_error_template.cpp(10): note: this candidate was rejected because at least one template argument could not be deduced
void function(const E &myEnum) {
^
compilation aborted for icl_error_template.cpp (code 2)
In general errors can be different but the source of them is that "sizeof(E::EnumMember)" is considered non-existent which is not true. Easy way to see that is to change condition to "sizeof(E::EnumMember) < 0"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can reproduce this failure, I opened CMPLRS-49370 in our internal bug tracking database. Thank you for reporting it! --Melanie

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