D Library Breakage
Steven Schveighoffer
schveiguy at yahoo.com
Fri Apr 13 20:19:48 UTC 2018
On 4/13/18 4:15 PM, Steven Schveighoffer wrote:
> I don't know if the compiler can determine if a version statement
> affects the layout, I suppose it could, but it would have to compile
> both with and without the version to see. It's probably an intractable
> problem.
Even when the layout is affected, it may not be a problem.
For example, in std.internal.cstring, we have this:
version(unittest)
// the 'small string optimization'
{
// 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
{
To[256 / To.sizeof] _buff; // production size
}
This results in the same size type whether you compile with unittests or
not.
Even if the compiler can tell "something's not the same", it may not be
a problem, as in this case.
-Steve
More information about the Digitalmars-d
mailing list