[Issue 5497] New: Cannot (reinterpret) cast string/array to different array inside CTFs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 27 13:37:26 PST 2011


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

           Summary: Cannot (reinterpret) cast string/array to different
                    array inside CTFs
           Product: D
           Version: 1.057
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: aziz.koeksal at gmail.com


--- Comment #0 from Aziz Köksal <aziz.koeksal at gmail.com> 2011-01-27 13:35:17 PST ---
Example code:

uint[] toArray(string s)
{
  return cast(uint[])s;
}
version(BigEndian)
static assert(toArray("\xdd\xcc\xbb\xaa")[0] == 0xddccbbaa);
else
static assert(toArray("\xdd\xcc\xbb\xaa")[0] == 0xaabbccdd);



// The following code works, of course:
static this()
{
version(BigEndian)
  assert(toArray("\xdd\xcc\xbb\xaa")[0] == 0xddccbbaa);
else
  assert(toArray("\xdd\xcc\xbb\xaa")[0] == 0xaabbccdd);
}

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


More information about the Digitalmars-d-bugs mailing list