[Issue 11785] New: Order of method/function declarations has an effect on compilation result.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 20 01:11:08 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11785

           Summary: Order of method/function declarations has an effect on
                    compilation result.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: kdmult at ya.ru


--- Comment #0 from kdmult <kdmult at ya.ru> 2013-12-20 01:11:07 PST ---
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);
}
---

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list