Don wrote:
Lars T. Kyllingstad wrote:
Can someone with knowledge of the DMD source code please explain
this error message for me?
dmd: glue.c:652: virtual void FuncDeclaration::toObjFile(int):
Assertion `!v->csym' failed.
I had a look at the DMD source to try and make some sense of it
myself, but didn't succeed. I am using the latest DMD, 2.029.
I am in the middle of porting a library from D1 to D2, and as there
is no mention of a file name, let alone a line number, I find it
hard to narrow down the cause of the error.
Thanks,
-Lars
Compile with -v, and you'll find the file DMD was working on when it
crashed. Please enter a test case into Bugzilla.
Thank you! Thanks to this little piece of advice, I've managed to
narrow it down enormously, and also to work around it. I'm having
problems reproducing it as a simple test case, though.
Using the -v switch, the last thing DMD says before bailing out is
"function qagiIntegrateUpper". So here's a snippet from the
troublesome code:
---
Result!(Real) qagiIntegrateUpper(Real, Func)
(Func f, Real a, Real epsAbs, Real epsRel, Workspace!(Real) workspace)
{
mixin AssertRealType!("qagiIntegrate", Real);
mixin AssertSignature!("qagiIntegrate", Func, Real, Real);
// Map onto the interval (0, 1).
auto trans = transform!(Func, "f(a + (1-t)/t)/(t*t)", a)(f);
return qagsIntegrate(trans, cast(Real)0.0, cast(Real)1.0,
epsAbs, epsRel, workspace, Rule.GK15);
}
---
The line that starts with "auto trans ..." is the one that causes
problems. The function transform!(...)(f) does what you think it
does; it takes the function f and transforms it according to the
string template parameter. The result is a struct with an opCall
method and a field containing a copy of the template parameter a
(which is passed to the template by alias).
I've been able to work around the error by replacing this line with
the following:
---
Real b = a;
auto trans = transform!(Func, "f(b + (1-t)/t)/(t*t)", b)(f);
---
Thus, what is passed on to transform() is a locally declared
variable, and not an argument to the function qagiIntegrateUpper().
Why this should matter, I have no idea.