mirror of
https://github.com/dlang/phobos.git
synced 2025-04-26 05:00:35 +03:00
* Fix #9585 Add check `variant` alignment There has been code that handles alignment for a long time now, and while this module is unlikely to be touched anymore, create a regression test so the issue can be closed. * Apparently double is 32bit aligned on x86
This commit is contained in:
parent
c79914db2d
commit
67afde4f10
1 changed files with 13 additions and 0 deletions
|
@ -3255,3 +3255,16 @@ if (isAlgebraic!VariantType && Handler.length > 0)
|
|||
immutable aa = ["0": 0];
|
||||
auto v = Variant(aa); // compile error
|
||||
}
|
||||
|
||||
// https://issues.dlang.org/show_bug.cgi?id=8195
|
||||
// Verify that alignment is respected
|
||||
@safe unittest
|
||||
{
|
||||
static struct Foo { double x; }
|
||||
alias AFoo1 = Algebraic!(Foo);
|
||||
static assert(AFoo1.alignof >= double.alignof);
|
||||
|
||||
// Algebraic using a function pointer is an implementation detail. If test fails, this is safe to change
|
||||
enum FP_SIZE = (int function()).sizeof;
|
||||
static assert(AFoo1.sizeof >= double.sizeof + FP_SIZE);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue