Bug 11785 – Order of method/function declarations has an effect on compilation result.
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-12-20T01:11:00Z
Last change time
2013-12-21T05:06:39Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
kdmult
Comments
Comment #0 by kdmult — 2013-12-20T01:11:07Z
If the templated overloaded method/function goes after the
non-templated one then the compilation fails.
FAILED:
long read( ubyte* bytes, long len ) { return 0; }
void read(T)( ref T val ) { read(cast(ubyte*)&val, cast(long)val.sizeof); }
Otherwise, if the templated overloaded function goes before the
non-templated one then the compilation is successful.
SUCCEEDED:
void read(T)( ref T val ) { read(cast(ubyte*)&val, cast(long)val.sizeof); }
long read( ubyte* bytes, long len ) { return 0; }
Test case 1.
---
module test;
class InputStream
{
long read( ubyte* bytes, long len ) { return 0; }
void read(T)( ref T val ) { read(cast(ubyte*)&val, cast(long)val.sizeof); }
}
void main()
{
auto input = new InputStream;
int v;
input.read(v);
}
---
Test case 2
---
module test;
long read( ubyte* bytes, long len ) { return 0; }
void read(T)( ref T val ) { read(cast(ubyte*)&val, cast(long)val.sizeof); }
void main()
{
int v;
read(v);
}
---