D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 11212 - Use of uninitialized struct allowed 2
Summary: Use of uninitialized struct allowed 2
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2013-10-09 14:00 UTC by Max Samukha
Modified: 2024-12-13 18:12 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Max Samukha 2013-10-09 14:00:29 UTC
Related to issue 11211

struct S {
    @disable this();

    bool cted;
    this(int x) {
        cted = true;        
    }

    void foo() {
        assert(cted);
    }
}

void bar(A a) {
    a.s.foo();   
}

class A {
    S s;
    this() {
        bar(this); // shouldn't compile
        s = S(1);
    }
}

void main() {
    auto a = new A;
}

Passing 'this' outside the constructor should be disallowed before structs with disabled constructors are initialized.

I could go on with bug reports but it is obvious that there is no good solution  in the face of current compilation model.
Comment 1 dlangBugzillaToGithub 2024-12-13 18:12:30 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18691

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB