The following code compiles and runs properly with gcc 8.2.0 (using -std=c++17).
It also compiles with icc 19.0.1.144, but throws a 'Floating point exception' when trying to access 'map' in the constructor.
#include <iostream>
#include <unordered_map>
struct A {
static inline std::unordered_map<int, int> map;
A(){
map[1] = 2;
}
};
int main(){
A a;
}A similar code with a primitive or 'std::vector' in place of 'std::unordered_map' does appears to work.
Am I missing something or is this a problem with the compiler?
This question was first posted here