Bug 13982 – D1: wrong template instantiation is not rejected
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2015-01-14T21:00:00Z
Last change time
2015-01-19T18:06:07Z
Assigned to
nobody
Creator
public
Comments
Comment #0 by public — 2015-01-14T21:00:52Z
void temp1 ( T ... ) ( char[] dest, T arrays )
{
temp2(dest, arrays[0]);
}
T[] temp2 ( T ) ( T[] dest, T[][] arrays )
{
return dest;
}
void main ( )
{
char[] email;
/*
*** Error in `dmd1': free(): invalid pointer: 0x00000000014451a0 ***
Aborted (core dumped)
*/
temp1!(int)(email, 12);
// ok
temp1(email, 12);
}
dmd2 rejects this code:
aaa.d(4): Error: template aaa.temp2 cannot deduce function from argument types !()(char[], int), candidates are:
aaa.d(7): aaa.temp2(T)(T[] dest, T[][] arrays)
aaa.d(20): Error: template instance aaa.temp1!int error instantiating
Comment #1 by bugzilla — 2015-01-16T22:31:37Z
When I run it with dmd1:
-----
C:\cbx\mars1>dmd foo
DMD v1.077 DEBUG
Enabled -v2 hints:
foo.d(5): Error: template foo.temp2(T) does not match any function template declaration
foo.d(5): Error: template foo.temp2(T) cannot deduce template function from argument types !()(char[],int)
foo.d(21): Error: template instance foo.temp1!(int) error instantiating
-----
Something is different between our versions of dmd1.
Comment #2 by public — 2015-01-16T22:32:51Z
Can you confirm that is also works with non-DEBUG version?
Comment #3 by public — 2015-01-16T22:34:35Z
Another difference is Linux64 vs Windows of course
Comment #4 by bugzilla — 2015-01-16T22:37:36Z
Ah, it works on Windows. I tried it on Linux and got the error you did. Hence, there's something wrong specifically with the Linux version.
Comment #5 by github-bugzilla — 2015-01-17T01:35:30Z