[Issue 3150] cast from dynamic array to ulong is allowed
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Mon May 10 02:01:14 PDT 2010
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=3150
--- Comment #2 from Don <clugdbug at yahoo.com.au> 2010-05-10 02:00:27 PDT ---
druntime currently relies on this behaviour in one place, and it's pretty nasty
code. For example, it assumes pointers are 32 bits long.
rt/lifetime.d
_d_newarraymT()
_d_newarraymiT()
These both cast a void[] to a ulong.
Instead of:
        result = cast(ulong)foo(ti, pdim, ndims);
should be: 
        static assert((void[]).sizeof == ulong.sizeof);       
        void[] r = foo(ti, pdim, ndims);
        result = *cast(ulong *)&r;
In fact, this is a very ugly bit of code. It only seems to be used in e2ir.c,
NewExp::toElem(), where there's another hack to get the .ptr out of the ulong.
I don't see any reason why extern(D) couldn't be used instead, so that it could
just return an array.
-- 
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