-
-
Notifications
You must be signed in to change notification settings - Fork 669
Open
Description
As of DMD 2.109.1, the following program fails to compile:
struct MustInit
{
int n;
@disable this();
this(int n) { this.n = n; }
}
struct S
{
MustInit member;
this(bool b, int n, int m)
{
if (b == true) {
member = MustInit(n);
return;
}
if (b == false) {
member = MustInit(m);
return;
}
assert(0); // unreachable
}
}The error message is:
bug.d(11): Error: constructor
bug.S.thisfieldmembermust be initialized but skipped
Since the code path that skips the initialization of member contains assert(0), and will never return, this code should be allowed to compile.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels