Thread overview | ||||||
---|---|---|---|---|---|---|
|
September 24, 2017 Struct alignment | ||||
---|---|---|---|---|
| ||||
DMD <= 2.074 and DMD >= 2.075 disagree on struct alignment. ``` struct UInt { align(1): uint a; } struct Bug { ubyte one; UInt two; } static assert(Bug.two.offsetof == 4); // Error DMD>=2.075, 1 == 4 is false static assert(Bug.sizeof == 8); // Error DMD>=2.075, 5 == 8 is false align(1) struct Align1UInt { align(1): uint a; } struct BugAlign1 { ubyte one; Align1UInt two; } static assert(BugAlign1.two.offsetof == 1); static assert(BugAlign1.sizeof == 5); // Error DMD<=2.074, 8 == 5 is false ``` So... what's correct? :-) Cheers, Johan |
September 24, 2017 Re: Struct alignment | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johan Engelen | On Sunday, 24 September 2017 at 21:01:06 UTC, Johan Engelen wrote:
> DMD <= 2.074 and DMD >= 2.075 disagree on struct alignment.
>
> ```
> struct UInt {
> align(1):
> uint a;
> }
>
> struct Bug {
> ubyte one;
> UInt two;
> }
>
> static assert(Bug.two.offsetof == 4); // Error DMD>=2.075, 1 == 4 is false
> static assert(Bug.sizeof == 8); // Error DMD>=2.075, 5 == 8 is false
>
> align(1)
> struct Align1UInt {
> align(1):
> uint a;
> }
>
> struct BugAlign1 {
> ubyte one;
> Align1UInt two;
> }
>
> static assert(BugAlign1.two.offsetof == 1);
> static assert(BugAlign1.sizeof == 5); // Error DMD<=2.074, 8 == 5 is false
> ```
>
> So... what's correct? :-)
>
> Cheers,
> Johan
Don't worry, this isn't a bug! It's a feature! It will just make your programs run faster! It won't get fixed! Don't want to break backwards compatibility, do we?
|
September 24, 2017 Re: Struct alignment | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johan Engelen | On Sunday, 24 September 2017 at 21:01:06 UTC, Johan Engelen wrote: > So... what's correct? :-) 2.075+. ;) See https://github.com/dlang/dmd/pull/6754. |
September 24, 2017 Re: Struct alignment | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | On Sunday, 24 September 2017 at 21:21:27 UTC, kinke wrote:
> On Sunday, 24 September 2017 at 21:01:06 UTC, Johan Engelen wrote:
>> So... what's correct? :-)
>
> 2.075+. ;)
> See https://github.com/dlang/dmd/pull/6754.
Thanks kinke.
(now on to fix LDC's codegen ;-)
|
Copyright © 1999-2021 by the D Language Foundation