Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of uninitialized struct allowed 2 #18691

Open
dlangBugzillaToGithub opened this issue Oct 9, 2013 · 0 comments
Open

Use of uninitialized struct allowed 2 #18691

dlangBugzillaToGithub opened this issue Oct 9, 2013 · 0 comments

Comments

@dlangBugzillaToGithub
Copy link

Max Samukha reported this on 2013-10-09T14:00:29Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=11212

Description

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant