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

Assertion failed: (isIrVarCreated(vd) && "Variable not resolved."), function DtoSymbolAddress, file ldc/gen/llvmhelpers.cpp, line 1773. #953

Closed
timotheecour opened this issue May 31, 2015 · 4 comments · Fixed by ldc-developers/dmd-testsuite#24

Comments

@timotheecour
Copy link

ldmd2 -release -c -of/tmp/z02 main.d

main.d:

void fun(string arg){
    import std.regex;
    assert(arg.match(``));
}

it works if we remove '-release' or if we have this:
auto temp=arg.match(); assert(temp); instead of assert(arg.match());

ldc2 --version
LDC - the LLVM D compiler (cf0589):
based on DMD v2.066.1 and LLVM 3.6.1
Default target: x86_64-apple-darwin14.3.0
Host CPU: core-avx2

@timotheecour timotheecour changed the title Assertion failed: (isIrVarCreated(vd) && "Variable not resolved."), function DtoSymbolAddress, file /Users/timothee/git_clone/D/ldc/gen/llvmhelpers.cpp, line 1773. Assertion failed: (isIrVarCreated(vd) && "Variable not resolved."), function DtoSymbolAddress, file ldc/gen/llvmhelpers.cpp, line 1773. May 31, 2015
@timotheecour
Copy link
Author

with -vv:

  • * * * * * * * Expression::toElemDtor(): assert((RegexMatch!(string, ThompsonMatcher) __tmpfordtor4035 = match(arg, regex("", ""));
    , __tmpfordtor4035).opCast(), cast(const(char)[])arg)
  • * * * * * * * * AssertExp::toElem: assert((RegexMatch!(string, ThompsonMatcher) __tmpfordtor4035 = match(arg, regex("", ""));
    , __tmpfordtor4035).opCast(), cast(const(char)[])arg)
  • * * * * * * * * CallExp::toElem: __tmpfordtor4035.~this() @ void
  • * * * * * * * * * DotVarExp::toElem: __tmpfordtor4035.~this @ nothrow @nogc @trusted void()
  • * * * * * * * * * * VarExp::toElem: __tmpfordtor4035 @ RegexMatch!(string, ThompsonMatcher)
  • * * * * * * * * * * * DtoSymbolAddress ('__tmpfordtor4035' of type 'RegexMatch!(string, ThompsonMatcher)')
  • * * * * * * * * * * * * a normal variable
    Assertion failed: (isIrVarCreated(vd) && "Variable not resolved."), function DtoSymbolAddress, file ldc/gen/llvmhelpers.cpp, line 1773.

@redstar
Copy link
Member

redstar commented May 31, 2015

Confirmed with GitHub master.

@redstar
Copy link
Member

redstar commented May 31, 2015

The __tmpfordtor is a generated variable which is used to call the destructor of RegexMacth!(). In release mode, the expression inside assert() is never evaluated/codegened. The __tmpfordtor variable is not initialized but still present in the AST - therefore we try to call the destructor.

The workaround does not have equal semantics. Here the call is always evaluated and the destructor is always run.

redstar added a commit to redstar/ldc that referenced this issue May 31, 2015
…are turned off.

Otherwise there is the possibility that temporaries are found and we try to call
the destructor on them.
This fixes issue ldc-developers#953.
@redstar
Copy link
Member

redstar commented May 31, 2015

I created a fix for this issue. Would be nice if someone could create a test case which does not depend on the standard library. (E.g. the test case does not compile with dmd from trunk.)

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 a pull request may close this issue.

2 participants