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

LDC crashes if imported module contains error #541

Closed
redstar opened this issue Nov 6, 2013 · 1 comment
Closed

LDC crashes if imported module contains error #541

redstar opened this issue Nov 6, 2013 · 1 comment

Comments

@redstar
Copy link
Member

redstar commented Nov 6, 2013

With the files thisbug.d

module thisbug;

import thisbuginc;

Foo create()
{
    return new Foo();
}

and thisbuginc.d

module thisbuginc;

//import std.algorithm;

class Foo
{
    struct Bar
    {
        int opCmp(ref const Bar rhs) const
        { return sortOrder(this, rhs); }

        private final static int sortOrder(ref const Bar a, ref const Bar b) {
            return 0;
        }
    }

    auto sortedBars(Bar[] bars) {
        return sort(bars);
    }
}

the command ldc2 -c thisbug.d prints an error message and crashes with release 0.12.0 (bad). If the merge-2.064 branch is used then ldc crashes with no error message printed (worse).

DMD compiles the module without problems.

A deeper analysis shows that the buggy types are referenced during vtable construction in the codegen phase. Because of the error, semantic3() has not been run. Then missing information leads to the crash.
DMD does not need the type information for the vtable construction and therefore compiles fine.

If you fix the bug (remove the comment) then ldc compiles the module, too.

redstar pushed a commit that referenced this issue Sep 27, 2014
@dnadlinger
Copy link
Member

In Git master, this now properly produces

thisbuginc.d(18): Error: undefined identifier sort

(I don't think it is a bug that we emit an error message when an imported module is broken.)

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

No branches or pull requests

2 participants