- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Below is a reproducer for an internal compiler error we hit with icpc 19.0.4 (with gcc 7.4 for STL, but that doesn't seem to have an effect):
#include <string>
#include <map>
struct StringMember {
std::string a = "";
// std::string a {}; //This works fine.
};
struct C {
StringMember mem = {};
};
struct B {
std::map<int, C> map_ {};
};
int main () {
return 1;
}
I tested on god bolt with icc 21.1.9 and it had the same behavior: https://godbolt.org/z/ePbf94 . Once we found the cause of the ICE, the work around is very simple (in comment above), but I figured I would report it in case it exposes something else.
Simon
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for posting in Intel C++ Compiler forum. We executed the reproducer code, like mentioned it threw an error. We found out that the error is due to the initialization. Initialization inside structure is done using constructor of that structure. The structure definition declares a type and not a variable that can be initialized. The comment mentioned(std::string a {}; //This works fine.) is for declaration only. Below is the recommended way of initialization. We tried it with icpc and it was working.
#include <string>
#include <map>
struct StringMember {
std::string a;
StringMember():a(""){}
// std::string a {}; //This works fine.
};
struct C {
StringMember mem ={};
};
struct B {
std::map<int, C> map_ {};
};
int main () {
return 1;
}
Regards
Gopika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was using the c++11 feature "default member initializer". The automatically generated default constructor should correctly default initialize the string with "". I have worked around it, but this is a bug. These default member initializers are recommended by the cpp core guidelines now, so I expect others may stumble upon this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Simon,
We’re forwarding this thread to the internal team who can help you out.
Regards
Gopika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've reported this bug to our Developer.
Thank for reporting this issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since there is a workaround. Hence, the version against which you reported your issue is no longer targeted for fixes. Please check out the new versions of Intel oneAPI Toolkits for the latest features.
I am going to close this thread. If you have any other questions/concerns please open a new thread.
Thanks,

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