Passing null array to template

Jonathan M Davis jmdavisProg at gmx.com
Mon Jul 18 11:14:39 PDT 2011


On 2011-07-18 10:44, David Nadlinger wrote:
> On 7/18/11 7:43 PM, Jesse Phillips wrote:
> > I'm wondering if this should be filed in Bugzilla. I'm guessing it
> > should. The blow should compile?
> > 
> > void main() {
> > 
> > example(null);
> > 
> > }
> > 
> > void example()(string[] foo) {
> > }
> > 
> > test.d(3): Error: template test.example() does not match any function
> > template declaration
> > test.d(3): Error: template test.example() cannot deduce template function
> > from argument types !()(void*)
> 
> If that doesn't compile, it is clearly a bug. Please do a quick search
> on Bugzilla and add this as a new issue if it is not already present.

It's always been that way, I believe, but I don't know if the issue is in 
bugzilla. Given that there's only one template overload that it could match, 
it should really match, but with multiple overloads, there _will_ be cases 
where you'd have to cast to the appropriate type even if this particular 
situation worked. It would be nice if it worked when there was no ambiguity 
though.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list