下面的示例代码对我来说看起来很好,但如果用GCC 4.0.2编译,则在Solaris上执行SIGBUS错误总是失败,但是如果用GCC 3.4.2版本编译,则运行良好。任何想法吗?
//params is a pointer to a structure Param, which has a member d whose type is double. It was initiated/allocated through JNI.
params->d = 5.0;
double *b = ¶ms->d;
double c = params->d;
c += *b;
SIGBUS在最后一行被引发,即解引用指针并访问内容是导致问题的原因。
谢谢,查尔斯。
这听起来像是对齐问题。IIRC, double
必须对齐到64位