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

Issue 7965 - Invalid outer function scope pointer in some cases #1014

Merged
merged 1 commit into from
Jun 21, 2012

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Jun 18, 2012

WalterBright added a commit that referenced this pull request Jun 21, 2012
Issue 7965 - Invalid outer function scope pointer in some cases
@WalterBright WalterBright merged commit 0b1ffa8 into dlang:master Jun 21, 2012
@MartinNowak
Copy link
Member

This triggers an assertion when compiling the following code.

void bug()
{
    struct Struct
    {
        void method() {}
    }
    auto val = Struct();
}

sd.fields->dim == 1 && elements != NULL && elements->dim == 0.

e2ir.c(5048):
        size_t dim = elements ? elements->dim : 0;
        if (sd->isNested() && dim == sd->fields.dim - 1)
            dim = sd->fields.dim;
        assert(dim <= sd->fields.dim);
        for (size_t i = 0; i < dim; i++)
        {   Expression *el = elements ? (*elements)[i] : NULL;

You have to compile dmd with -DDEBUG=1 to turn on array bounds checks.

@9rnsr
Copy link
Contributor Author

9rnsr commented Jun 22, 2012

What code is really broken? I can't reproduce the 'assertion' in Windows...

@MartinNowak
Copy link
Member

It's an array bounds violation (dim > elements->dim).
Somehow the StructDeclaration has one field (the hidden this I suppose) but the StructLiteral has an empty but non-zero elements array. I haven't investigated it further so I don't know the root cause.

@9rnsr
Copy link
Contributor Author

9rnsr commented Jun 22, 2012

It's an array bounds violation (dim > elements->dim).

Ouch... It's my mistake. Thanks for the reporting. I'll post a pull for fixing.

9rnsr added a commit to 9rnsr/dmd that referenced this pull request Jun 23, 2012
WalterBright added a commit that referenced this pull request Jun 23, 2012
Fix access violation introduced by merging pull #1014
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.

3 participants