Thread overview
[Issue 3133] New: Compiler does not check that static array casts are legal
Jul 03, 2011
yebblies
Oct 03, 2011
Walter Bright
July 04, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3133

           Summary: Compiler does not check that static array casts are
                    legal
           Product: D
           Version: 1.039
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: jarrett.billingsley@gmail.com


When doing casts on dynamic arrays, invalid casts (i.e. where the sizes of the source and destination arrays do not have a 0 remainder) are correctly diagnosed as an error:

short[] x = [1];
int[] y = cast(int[])x; // error, array cast misalignment

The equivalent operation performed on static arrays should be diagnosable at compile-time, but isn't:

short[1] x = [1];
int[1] y = cast(int[1])x; // accepted, even though illegal
writefln("%s", y[0]); // prints garbage

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 03, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3133


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |yebblies@gmail.com


--- Comment #1 from yebblies <yebblies@gmail.com> 2011-07-03 18:41:51 EST ---
https://github.com/D-Programming-Language/dmd/pull/201

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


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2011-10-02 20:58:14 PDT ---
https://github.com/D-Programming-Language/dmd/commit/6f37208535a69a79474b52d9755c46921961e7e1

https://github.com/D-Programming-Language/dmd/commit/3abfaea0c0ad70369a3d1d446c394cb47f0ec55a

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