September 22, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2469


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
         OS/Version|Linux                       |All


--- Comment #10 from Don <clugdbug@yahoo.com.au> 2009-09-22 01:07:54 PDT ---
The root cause is that all kinds of nonsense is allowed in struct casts. Explicit struct casts only make sense when the source and destination are of the same size.

Patch against DMD 2.032.

Index: cast.c ===================================================================
--- cast.c    (revision 196)
+++ cast.c    (working copy)
@@ -822,6 +822,15 @@
             return e;
         }
         }
+        // Struct casts are possible only when the sizes match
+        if (typeb->ty==Tstruct || tb->ty==Tstruct) {
+        size_t fromsize = tb->size(loc);
+        size_t tosize = typeb->size(loc);
+        if (fromsize !=tosize) {
+            error("Cannot cast from %s to %s", type->toChars(), t->toChars());
+            return this;
+        }
+        }
         e = new CastExp(loc, e, tb);
     }
     }

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


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #11 from Walter Bright <bugzilla@digitalmars.com> 2009-10-06 02:14:23 PDT ---
Fixed dmd 1.048 and 2.033

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
1 2
Next ›   Last »