undefined references

Vlad Levenfeld via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 10 20:12:43 PDT 2014


Ok, I've gotten to the bottom of this issue but I'm not totally 
sure how to submit a bug report for this (no SSCCE: can't get 
dustmite to work on it, and the problem won't show itself when I 
use the offending module in isolation) so I will try to sum up 
the issue and maybe I can provide some useful information for the 
devs.

I have a generic Vector struct that is constructed by helper 
functions that deduce the length and element type and forward the 
arguments to the appropriate constructor. Almost all of them had 
a constraint on them that required the length of the vector the 
be at least 2, but the Vector class itself had no such 
constraint, and one of the helper functions was missing it as 
well.

When I added the constraint to either the Vector struct or the 
helper function (I've since added them to both) then everything 
links fine. It looks like what was happening was that a "fill 
constructor helper function" (intended use: vector!4 (x) => 
vector (x, x, x, x)) was routing to a "variadic constructor 
helper function" (vector (args) => vector!(args.length)(args)) 
that attempted to generate a 1-element vector and somewhere along 
the way - linker error.

There are the mangled names that the linker could not resolve 
references to:

`_D3evx7vectors16__T6VectorVm1TdZ6Vector6__initZ`

`_D3evx7vectors16__T6VectorVm1TdZ6Vector6__ctorMFNaNbNcNfdZS3evx7vectors16__T6VectorVm1TdZ6Vector`

the second of which demangles to this:

pure nothrow ref @safe evx.vectors.Vector!(1uL, double).Vector 
evx.vectors.Vector!(1uL, double).Vector.__ctor(double)

So, there's my one-element vector constructor, which is likely 
having a hard time with the following overloads:

	this (Elements...)(Elements elements)
	if (Elements.length == length)
	{
		foreach (i, element; elements)
			components[i] = element;
	}
	this (Element element)
	{
		components[] = element;
	}

So, while the mistake was mine, this should be an ambiguous 
overload error at compile-time, instead of a linker error.

I realize that everyone contributing to D has their hands more 
than full, and a bug this rare (assumption based on lack of 
search results) is gonna be low-priority, so I'm just making this 
post for posterity - maybe it'll help, and of course I'm happy to 
try anything and give additional information. If anyone has any 
suggestions on how I might go about making a useful bug report 
out of this, I'm all ears.


More information about the Digitalmars-d-learn mailing list