Skip to content

Fix spurious 'default construction is disabled' error for class#23393

Open
ntrel wants to merge 1 commit into
dlang:masterfrom
ntrel:class-struct-disable
Open

Fix spurious 'default construction is disabled' error for class#23393
ntrel wants to merge 1 commit into
dlang:masterfrom
ntrel:class-struct-disable

Conversation

@ntrel

@ntrel ntrel commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #23392.
Bug introduced in #23212.

// Look for misaligned pointer, etc., in @safe mode
err |= checkUnsafeAccess(sc, arg, false, true);
err |= checkDefCtor(arg.loc, t); // t must be default constructible
if (!t.isClassHandle())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!t.isClassHandle())
if (!t.baseElemOf().isTypeClass())

So it also works with enums and static arrays

enum E : Client { a = null }
void sinkArr(out Client[3] r) {}
void sinkEnumArr(out E[3] r) {}

@dkorpel

dkorpel commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Thanks for investigating this so quickly!

@thewilsonator thewilsonator left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

struct Parser { @disable this(); this(int) {} }
class Client { Parser parser; this() { parser = Parser(0); } }
void sink(out Client r) {}
void main() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compilable test should not contain a main, rename test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI suddenly broke with DMD nightly

3 participants