Thread overview
[Issue 2995] New: Incorrect conversion in c ? a : b
Apr 04, 2010
Don
May 06, 2010
Don
May 17, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2995

           Summary: Incorrect conversion in c ? a : b
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: andrei@metalanguage.com


class A {}

void main()
{
    immutable(A) b;
    A c;
    auto z = true ? b : c;
    writeln(typeof(z).stringof);
}

writes Object, which is wrong in a number of ways. The common type of A and
immutable(A) is const(A).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 04, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2995


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-04-04 08:22:46 PDT ---
PATCH: cast.c, line 1663. Conversion of both types to const needs to occur for classes, as well as for arrays and pointers.

    else if (t1->ty == Tclass || t2->ty == Tclass)
    {
+        if (t1->mod != t2->mod)
+        {
+            t1 = t1->mutableOf()->constOf();
+            t2 = t2->mutableOf()->constOf();
+            t = t1;
+            goto Lagain;
+        }
        while (1)
        {
            int i1 = e2->implicitConvTo(t1);
            int i2 = e1->implicitConvTo(t2);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 06, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2995


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2010-05-05 19:19:37 PDT ---
Fixed DMD2.044.

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