Tag: segmentation-fault

Declaring a global structure causes a segmentation fault but when localized it is fine? [duplicate]

问题内容: This question already has an answer here: Is it OK to access past the size of a structure via member address, with enough space allocated? 3 answers As the title suggests, when I declare structure BasicSetup_S globally, I get a segmentation fault. But if I move BasicSetup_S into CallFunction() the segmentation fault goes away.