http://d.puremagic.com/issues/show_bug.cgi?id=2469


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

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


--- Comment #10 from Don <clugd...@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: -------

Reply via email to