- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have found a possible type-deduction bug, reproducible in Intel 18.0.1, 18.0.2, and 19.0.0.046. Here is a small code snippet demonstrating the issue:
https://gist.github.com/abrooks98/020b3a499e2dbedd0c7cc81e50982152
#include <vector> #include <utility> #include <stdio.h> template<typename T> class myvector : public std::vector<T> {}; template<typename T> struct check_for { template<typename U> static constexpr bool _data(U*, decltype(std::declval<U>().data())* = nullptr) { return true; } template<typename U> static constexpr bool _data(...) { return false; } template<typename U> static constexpr bool _get_allocator(U*, decltype(std::declval<U>().get_allocator())* = nullptr) { return true; } template<typename U> static constexpr bool _get_allocator(...) { return false; } static constexpr bool data = _data<T>(nullptr); static constexpr bool get_allocator = _get_allocator<T>(nullptr); }; int main(int argc, char** argv) { printf("Check type 'bool' for function 'data': %d\n", check_for<bool>::data); printf("Check type 'std::vector<int>' for function 'data': %d\n", check_for<std::vector<int>>::data); printf("Check type 'myvector<int>' for function 'data': %d\n", check_for<myvector<int>>::data); printf("Check type 'bool' for function 'get_allocator': %d\n", check_for<bool>::get_allocator); printf("Check type 'std::vector<int>' for function 'get_allocator': %d\n", check_for<std::vector<int>>::get_allocator); printf("Check type 'myvector<int>' for function 'get_allocator': %d\n", check_for<myvector<int>>::get_allocator); decltype(std::declval<std::vector<int>>().get_allocator()) a; int* b = a.allocate(10); printf("%p\n", b); a.deallocate(b, 10); return 0; }
The issue is that check_for<std::vector<int>>::get_allocator should return true, but it does not. The type-deduction does work for some functions, however. For example, check_for<std::vector<int>>::data returns true. This issue is not present in GCC (tested with 4.9.3 and 7.1.0) or Clang (tested with 3.9.0 and 4.0.0)
- 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 Alex,
Can you provide us your command line options?
Thanks,
Viet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Viet,
Of course. I am simply using:
icpc -std=c++11 main.cpp
That is also the only flag I used to test with other compilers as well.
Thanks,
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Alex,
I've filed a bug report with our developer. The internal tracking number is: CMPLRS-51086
Viet

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