c++ - "Bus error"从结构访问集合<int>

标签 c++ stl struct bus-error

搜索了一段时间,但我不明白为什么这会引发总线错误。

如有任何帮助,我们将不胜感激。

typedef struct {
   set<int> pages;
} someStruct;
...
void someFunction() {
   ...
   someStruct *a = createSomeStruct(); // just mallocs and returns
   a->pages.insert(5);
   ...
}

最佳答案

malloc 不会初始化它分配的内存。尝试新的。

关于c++ - "Bus error"从结构访问集合<int>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/601680/

相关文章:

c++ - 平衡二叉搜索树 (BST)

C++ STL 堆栈 : When is it safe to pop()

c - 在Linux中使用C读取文件时出现段错误

c - 套接字上具有数据数组的C结构

c - 指向结构的指针数组的动态分配

c++ - 如何设置 XAudio2 dll 版本

c++ - uint128_t 没有命名类型

c++ - 具有启用/禁用功能的匿名结构

c++ - 关于如何实现的想法?

C++ - 如何知道 map::upper_bound() 是否没有返回值?