www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2995] New: Incorrect conversion in c ? a : b

reply d-bugmail puremagic.com writes:
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: -------
May 16 2009
next sibling parent d-bugmail puremagic.com writes:
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: -------
Apr 04 2010
prev sibling parent d-bugmail puremagic.com writes:
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: -------
May 05 2010