[求助]如何 Debug C++ release build 报 Address boundary error, debug build 正常运行的 bug?

2022-01-27 18:05:08 +08:00
 deepkolos

如题 RT

910 次点击
所在节点    问与答
5 条回复
SJ2050cn
2022-01-27 18:42:03 +08:00
这种 release 模式报错,debug 模式没报错我之前遇到过,简单的说就是 debug 模式会默认做一些事情,譬如内存初始化,而 release 不会做这些默认的事情,我当时是发现自己的数组从 1 开始初始化了,好好检查一下自己程序中变量的初始化情况吧。
ysc3839
2022-01-27 18:55:47 +08:00
发代码
BrettD
2022-01-27 20:53:59 +08:00
开 Sanitizer 调试测试
lixile
2022-01-28 10:16:41 +08:00
方向太多了
1 、编译选项不一样会导致有不同的机器码
2 、debug 和 release 在代码内部编译宏差异
3 、dgb 也能稍微调一点没有 strip 过的 release 版本
deepkolos
2022-02-08 14:50:35 +08:00
@ysc3839 定位的是一个 union 导致

```cpp
struct Matrix4 {
union {
float elements[16] {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
struct {
float m0; float m1; float m2; float m3;
float m4; float m5; float m6; float m7;
float m8; float m9; float m10; float m11;
float m12; float m13; float m14; float m15;
};
struct {
float col0[4];
float col1[4];
float col2[4];
float col3[4];
};
// 定位到是这里, 把这个删除就可以了...
struct {
_m128 simd_t[4];
};
};

// 方法省略了
}
```

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/830989

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX