[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] i386 Double alignment- bug?
From: |
Mike Henning |
Subject: |
Re: [Tinycc-devel] i386 Double alignment- bug? |
Date: |
Tue, 19 Sep 2006 15:23:53 -0700 (PDT) |
--- Daniel Glöckner <address@hidden> wrote:
> On Tue, Sep 19, 2006 at 09:56:17AM -0700, Mike
> Henning wrote:
> > I noticed that the sizeof a double is returned as
> 8,
> > which should be correct, but 4 is returned in
> align.
>
> This is correct behaviour on x86 Linux.
> GCC has a command line switch to align doubles to 8
> bytes.
>
> > #pragma pack(8)
> > typedef struct _foo
> > {
> > char a;
> > int v1;
> > int v2;
> > double d1;
> > }foo;
> >
> > sizeof(foo) = 20 regardless of the pack value set.
> > Using the above example it should return 24.
>
> No, it shouldn't.
> Pragma pack sets the maximum alignment as is
> described here:
>
http://msdn2.microsoft.com/en-us/library/2e70t5y1.aspx
>
> Anyway, pragma pack is non-standard and TinyCC is
> allowed to do whatever
> it wants. It just so happens, that TinyCC behaves
> the same way MSVC does.
>
> > So should align be returning 8 here?
>
> Only if you are using TinyCC in Windows.
>
Sorry, I should have mentioned that I'm working under
Windows.
Maybe the this should be written as:
#if defined(TCC_TARGET_I386) && !defined(WIN32)
*a = 4;
#else
*a = 8;
#endif
return 8;
Thanks,
Mike H.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com