Skip to content

Commit

Permalink
Fix issue 18084 - tempCString type should not change layout when used in
Browse files Browse the repository at this point in the history
unittests.
  • Loading branch information
schveiguy committed Dec 19, 2017
1 parent 5e17662 commit 4873e2f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions std/internal/cstring.d
Expand Up @@ -218,17 +218,20 @@ private:

To* _ptr;
size_t _length; // length of the string

// the 'small string optimization'
version (unittest)
{
enum buffLength = 16 / To.sizeof; // smaller size to trigger reallocations
// smaller size to trigger reallocations. Padding is to account for
// unittest/non-unittest cross-compilation (to avoid corruption)
To[16 / To.sizeof] _buff;
To[(256 - 16) / To.sizeof] _unittest_pad;
}
else
{
enum buffLength = 256 / To.sizeof; // production size
To[256 / To.sizeof] _buff; // production size
}

To[buffLength] _buff; // the 'small string optimization'

static TempCStringBuffer trustedVoidInit() { TempCStringBuffer res = void; return res; }
}

Expand Down

0 comments on commit 4873e2f

Please sign in to comment.