Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alignments in std.variant.Algebraic #9585

Open
dlangBugzillaToGithub opened this issue Sep 29, 2011 · 4 comments
Open

Alignments in std.variant.Algebraic #9585

dlangBugzillaToGithub opened this issue Sep 29, 2011 · 4 comments

Comments

@dlangBugzillaToGithub
Copy link

bearophile_hugs reported this on 2011-09-29T11:07:53Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=6742

CC List

Description

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() {}
@dlangBugzillaToGithub
Copy link
Author

lovelydear commented on 2012-04-27T15:05:18Z

Compiles and runs on 2.059 Win32

@dlangBugzillaToGithub
Copy link
Author

bearophile_hugs commented on 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.

@dlangBugzillaToGithub
Copy link
Author

andy commented on 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.

@dlangBugzillaToGithub
Copy link
Author

bugzilla (@WalterBright) commented on 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.

@thewilsonator thewilsonator removed P3 OS:Windows Issues Specific to Windows Arch:x86 Issues specific to x86 labels Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants