开发者

GCC 4.0.2 dereference pointer to double type member of structure raises SIGBUS error

The follow sample code looks OK to me but always fails executing on Solaris with SIGBUS error if compiled with GCC 4.0.2, however it runs fine if compiled with GC开发者_StackOverflow社区C 3.4.2 version. Any thought?

        //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 = &params->d;
        double c = params->d;
        c += *b;

SIGBUS was raised at the last line, i.e. dereferencing the pointer and accessing the content is causing the problem.

Thanks, Charles


That sounds like an alignment issue to me. IIRC, double has to be aligned to 64 bit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜