Eliminate class allocators and deallocators?

Denis Koroskin 2korden at gmail.com
Thu Oct 8 04:26:37 PDT 2009


On Thu, 08 Oct 2009 14:48:19 +0400, Steven Schveighoffer  
<schveiguy at yahoo.com> wrote:

> On Wed, 07 Oct 2009 17:54:35 -0400, Denis Koroskin <2korden at gmail.com>  
> wrote:
>
>> On Wed, 07 Oct 2009 23:00:06 +0400, Sean Kelly <sean at invisibleduck.org>  
>> wrote:
>>
>>> auto x = cast(MyClass) malloc(MyClass.classinfo.init.length);
>>
>> I would expect a dynamic cast to occur at this line. Which will either  
>> result in an access violation (since you are trying to cast a garbage  
>> to an object) or result in a null being returned.
>
> malloc returns void *, so no dynamic cast.
>
> -Steve

I know malloc returns void*. I didn't know you can hijack type system that  
easily.

But then, if no dynamic cast takes place why cast(Object)cast(void*)0  
cannot be evaluated at compile time?



More information about the Digitalmars-d mailing list