- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I found that intel c++ compiler behaves suspiciously for constexpr member variable of a template class. With
$ icpc -v icpc version 19.0.5.281 (gcc version 8.3.0 compatibility)
The following code print nothing.
#include <iostream> template<typename T> struct Derived { constexpr static char test_[] = "test"; }; /* These lines are useless in C++17 template<typename T> constexpr char Derived<T>::test_[]; */ int main() { std::cout << Derived<double>::test_ << std::endl; //print nothing return 0; }
I just used '-std=c++17' option. GCC version 8 compiles the code and print "test" as expected. I strongly suspect that GCC's behavior is the standard and ICC is buggy.
In addition, ICC version 2019.3.199 does not compile the code and print error "incomplete type is not allowed".
Best,
- Tags:
- Bug
- 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,
Thanks for reporting this bug. We will take this issue to the concerned team.
I have tried to reproduce this issue with icpc version 19.1 20200303.
With icpc, -std=c++17 flag, I'm able to compile the code, but it doesn't print anything. With gcc it prints the output correctly.
However, with icpc and -std=c++14, the code compiles and prints the output correctly after adding "constexpr char Derived<T>::test_[];" (Commented part of your code).
--Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've reported this bug to our Compiler Developer. Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Rahul and Viet,
Thanks for your quick responses. I also found that the polymorphic feature of the cereal c++ library (https://uscilab.github.io/cereal/polymorphism.html) does not work because of this issue. I hope it to be fixed in the next release of icc.
Best,
Chae-Yeun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
The error you have reported on icc/icpc will be fixed in future releases.
Meanwhile, we have tried your sample code with icpx and didn't see any issue.
Please try icpx and let us know if that helps.
Regards
Prasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
As we have not heard back from you, we are closing this thread. So we will no longer respond to this thread. If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only
Have a Good day!
Thanks & Regards
Goutham

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