Bug 6742 – Alignments in std.variant.Algebraic

Status
NEW
Severity
normal
Priority
P3
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2011-09-29T11:07:53Z
Last change time
2024-12-01T16:14:29Z
Keywords
bootcamp
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: phobos#9585 →

Comments

Comment #0 by bearophile_hugs — 2011-09-29T11:07:53Z
In DMD 2.056head std.variant.Algebraic seems to ignore alignment requirements: import std.variant: Algebraic; static assert(double.alignof == 8); struct Foo { double x; } alias Algebraic!(Foo) AFoo1; static assert(AFoo1.sizeof == 12); struct AFoo2 { bool b; double x; } static assert(AFoo2.sizeof == 16); void main() {}
Comment #1 by lovelydear — 2012-04-27T15:05:18Z
Compiles and runs on 2.059 Win32
Comment #2 by bearophile_hugs — 2012-05-22T15:22:50Z
(In reply to comment #1) > Compiles and runs on 2.059 Win32 That's the problem. I think AFoo1.sizeof has to be 16 byte, to respect the algnment of doubles that is 8.
Comment #3 by andy — 2015-01-30T02:40:46Z
In DMD 2.066.1, I get: import std.variant: Algebraic; static assert(double.alignof == 8); // Error here, this should be 4. struct Foo { double x; } alias Algebraic!(Foo) AFoo1; static assert(AFoo1.sizeof == 12); struct AFoo2 { bool b; double x; } static assert(AFoo2.sizeof == 16); // Error here, it should be 12. void main() {} I'm not sure what that means though.
Comment #4 by bugzilla — 2019-12-03T10:14:21Z
On linux, the current compile reports 8 / 16 / 16. As far as I understand this, this is correct. Did not test windows though.
Comment #5 by robert.schadek — 2024-12-01T16:14:29Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9585 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB