Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Ticket #338 (new defect)

Opened 3 years ago

Last modified 3 years ago

Assertion failure on cast(ulong)void[]

Reported by: mrmonday Assigned to: lindquist
Priority: major Milestone:
Component: backend Version: hg tip
Keywords: Cc:

Description

The following causes an assertion in both ldc and ldc2:

void main()
{
    void[] foo;
    ulong u = cast(ulong)foo;
}

Assertion: gen/arrays.cpp:1019: DValue* DtoCastArray?(Loc&, DValue*, Type*): Assertion `0' failed.

This is a blocker for ldc2 as it is used in druntime.

Change History

07/07/09 09:54:14 changed by mrmonday

Also affects byte, ubyte, short, ushort, int, uint, long, float, double, real, char, wchar and dchar.

07/07/09 13:51:00 changed by ChristianK

  • owner changed from ChristianK to lindquist.
  • component changed from unspecified to backend.

Note that in DMD all casts are an error (Error: e2ir: cannot cast from void[] to ...) but the ulong one. And cast(ulong)foo seems to yield foo.length? In what context is this used in druntime?

08/02/09 12:06:58 changed by lindquist

it yields the length because the array reference is null. with a real array containing data, it performs a reinterpreting cast. I've seen this when I ported the first LDC runtime from DMD's, and they're all changed in LDC due to the non-portable nature of this optimization hack.

I'm not sure allowing this is a good idea at all ?

08/08/09 11:02:39 changed by mrmonday

When porting druntime I switched it over the same way you did with LDC's runtime. As for whether to allow it... sounds like something that needs to be in the spec? Time for another spec bug in bugzilla?

Copyright © 2008, LDC Development Team.