mercredi 23 octobre 2019

Declaring non-intrinsic types with () after variable name has different behavior than without. i.e. std::map

I have a member variable declaration of: std::map<int,char>x; in my header file. It compiles, but when I run my binary I get a segfault in the initialization of the class, before I even get into the constructor. If I change the declaration to std::map<int,char>x(); -i.e. I just added a () after the variable name - it works fine, no segfault.

I can't give any more specific example than the above, but if anyone has experience with this I'd be interested to know what's going on.

Compiler version is gcc version 4.8.5 target is x86_64-redhat-linux

I realize this is fairly nonspecific but I'm only looking for a general answer.

Thanks.

Aucun commentaire:

Enregistrer un commentaire