www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6705] New: Bad codegen when passing fields as template alias params

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6705

           Summary: Bad codegen when passing fields as template alias
                    params
           Product: D
           Version: D2
          Platform: x86
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: thecybershadow gmail.com



02:22:48 PDT ---
I'm not sure if this is valid code, so it's either accepts-invalid or
wrong-code.
I was trying to implement member field pointers, when I ran into this:

int func(alias F)(int i)
{
    return i;
}

class C
{
    int a;
}

void main()
{
    auto a = &func!(C.a);
    assert(a(5) == 5);
    //auto i = func!(C.a)(5); // uncomment for a weird compiler error
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 21 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6705


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid, wrong-code
                 CC|                            |smjg iname.com



From what I can make out, the code is valid - a class member falls under "any
type of D symbol", and func!anything is just an int(int) function.

For me (2.057 Win32), the given code throws an AV at runtime (wrong-code). 
Reinstating the commented out line gives

C:\Users\Stewart\Documents\Programming\D\Tests\bugs>dmd bz6705.d
bz6705.d(15): Error: need 'this' to access member func
(rejects-valid)

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