std.format and uninitialized elements in CTFE
mipri
mipri at minimaltype.com
Thu Dec 5 20:56:55 UTC 2019
On Thursday, 5 December 2019 at 19:56:35 UTC, kinke wrote:
> there's no such thing as uninitialized struct/class *members*,
> there are only uninitialized whole struct instances.
Is that true in CTFE?
Consider:
import std.format;
struct Foo
{
int a = void;
int b;
}
static x = format("%s", Foo().a);
static y = format("%s", Foo().b);
The second format succeeds on its own.
The first fails with
Error: cannot read uninitialized variable a in CTFE
More information about the Digitalmars-d
mailing list