Skip to content

Commit

Permalink
Added unittests for fixed std.typecons.scoped alignment issue.
Browse files Browse the repository at this point in the history
* issue fixed in commit 9cf123a
  • Loading branch information
denis-sh committed Oct 28, 2012
1 parent deb33d0 commit 3e0f69c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions std/typecons.d
Expand Up @@ -3128,17 +3128,24 @@ unittest // Issue 6580 testcase
static assert(scoped!C7().sizeof % alignment == 0);

enum longAlignment = long.alignof;
static class C1long { long l; byte b; }
static class C2long { byte[2] b; long l; }
static class C1long
{
long l; byte b = 4;
this() { }
this(long _l) { l = _l; }
}
static class C2long { byte[2] b = [5, 6]; long l = 7; }
static assert(scoped!C1long().sizeof % longAlignment == 0);
static assert(scoped!C2long().sizeof % longAlignment == 0);

void alignmentTest()
{
auto c1long = scoped!C1long();
auto c1long = scoped!C1long(3);
auto c2long = scoped!C2long();
assert(cast(size_t)&c1long.l % longAlignment == 0);
assert(cast(size_t)&c2long.l % longAlignment == 0);
assert(c1long.l == 3 && c1long.b == 4);
assert(c2long.b == [5, 6] && c2long.l == 7);
}

alignmentTest();
Expand Down

0 comments on commit 3e0f69c

Please sign in to comment.