This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Alignment option


> From: "Philippe Bonneau" <phbonneau@hotmail.com>
> To: gcc@gcc.gnu.org
> Date: Fri, 11 Aug 2000 15:39:34 CEST

> I'm having a a problem using the pragma pack with gcc version 2.95.1 on 
> solaris and sparc system.

> ie:

> #pragma pack(4)
> struct testStruct
> {
> ..
>    double var;
> }
> #pragma pack()


> void test(double* src)
> {
>    double dst;
>    dst = *src;
> }

> and naturally, the SIGBUS error occurs when:

> testStruct s;
> test(&s.var);

This is a bug in the compiler.  The type of &s.var isn't double *, and
should not implicit convert to a double* either.  What it is, is a
pointer to an unaligned double.  It is a type violation to use a
double value when that double value is actually an unaligned double.
The only access permitted is by way of an unaligned double.

> Even when I tried to compile with -munaligned-doubles, it didn't resolve the 
> problem. Which flag must be set?

No flag, the code is wrong as well as the compiler.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]