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); } ---
Comment #1 by k.hara.pg — 2013-12-20T02:07:52Z
Comment #2 by github-bugzilla — 2013-12-20T23:56:50Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/bdf6d81f723b33c10c84cfebef3e22ade94d32e2 fix Issue 11785 - Order of method/function declarations has an effect on compilation result https://github.com/D-Programming-Language/dmd/commit/691f08a6841acded5b403610931421cdcfb2751d Merge pull request #2993 from 9rnsr/fix11785 Issue 11785 - Order of method/function declarations has an effect on compilation result