[Issue 13283] New: dmd fails to generate ambiguous overload error
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Aug 11 04:35:47 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13283
Issue ID: 13283
Summary: dmd fails to generate ambiguous overload error
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: vlevenfeld at gmail.com
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 struct 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.
--
More information about the Digitalmars-d-bugs
mailing list