www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6777] New: alias this + cast(void*) == bug

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

           Summary: alias this + cast(void*) == bug
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dsimcha yahoo.com



struct S {}

class C {
    S s;
    alias s this;
}

void main() {
    auto c = new C;
    auto p = cast(void*) c;
}

test.d(10): Error: cannot cast from S to void*

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 06 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6777




I think this is right behavior.
In D2, the implicit conversion from class type to void* is disabled. So

    auto p = cast(void*) c;

the expression c is transformed to c.s, and cause an error.

----

void main()
{
    Object o;
    void* p = o;
    // test.d(4): Error: cannot implicitly convert expression (o) of type
object.Object to void*
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 23 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6777


timon.gehr gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr gmx.ch




 I think this is right behavior.
 In D2, the implicit conversion from class type to void* is disabled. So
 
     auto p = cast(void*) c;
 
 the expression c is transformed to c.s, and cause an error.
 
auto p = cast(void*) c; works if there is no alias this;. Implicit conversion rules are irrelevant, because this is an explicit conversion. Therefore, I think this is definitely a bug, because adding alias this should never disable features to work, it should only be considered if the code would not compile otherwise. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 23 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6777


Lukasz Wrzosek <luk.wrzosek gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason.james.house gmail.com



PST ---
*** Issue 2929 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6777


Maksim Zholudev <maximzms gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |samukha voliacable.com



PST ---
*** Issue 7985 has been marked as a duplicate of this issue. ***

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