Thread overview
pragma
Variadic functions cause TypeInfo casts to fail says...
Aug 07, 2005
pragma
Aug 07, 2005
Ben Hinkle
Re: Variadic functions cause TypeInfo casts to fail
Aug 08, 2005
pragma
Aug 08, 2005
Ben Hinkle
Aug 08, 2005
pragma
Aug 09, 2005
Thomas Kühne
August 07, 2005
Has this been reported yet?  This happens with DMD 0.129 (and possibly earlier
versions as well).

# void main(){
# 	bit isArray(...){
# 		return cast(TypeInfo_Array)_arguments[0] !is null;
# 	}
# 	char[] foobar;
# 	assert(isArray(foobar));
# }

The above fails the assert since the cast from _arguments[0] to TypeInfo_Array returns null.  This only fails with variadic functions: casting from typeid() works fine, even in templates.

- EricAnderton at yahoo
August 07, 2005
Boy, I hosed that up real good.  Here's the second try:

Has this been reported yet?  This happens with DMD 0.129 (and possibly earlier
versions as well).

# void main(){
# 	bit isArray(...){
# 		return cast(TypeInfo_Array)_arguments[0] !is null;
# 	}
# 	char[] foobar;
# 	assert(isArray(foobar));
# }

The above fails the assert since the cast from _arguments[0] to TypeInfo_Array returns null.  This only fails with variadic functions: casting from typeid() works fine, even in templates.

- EricAnderton at yahoo

- EricAnderton at (needs-to-check-the-form-first) yahoo
August 07, 2005
"Variadic functions cause TypeInfo casts to fail" <Variadic_member@pathlink.com> wrote in message news:dd60j3$10ki$1@digitaldaemon.com...
> Has this been reported yet?  This happens with DMD 0.129 (and possibly
> earlier
> versions as well).
>
> # void main(){
> # bit isArray(...){
> # return cast(TypeInfo_Array)_arguments[0] !is null;
> # }
> # char[] foobar;
> # assert(isArray(foobar));
> # }
>
> The above fails the assert since the cast from _arguments[0] to
> TypeInfo_Array
> returns null.  This only fails with variadic functions: casting from
> typeid()
> works fine, even in templates.
>
> - EricAnderton at yahoo

I couldn't get typeid(char[]) to cast to TypeInfo_Array - are you sure you were able to? Note if you look at src/phobos/std/typeinfo/ti_Aa.d is says char[]'s typeinfo subclasses TypeInfo not TypeInfo_Array.


August 08, 2005
In article <dd62kj$12a9$1@digitaldaemon.com>, Ben Hinkle says...
>
>
>"Variadic functions cause TypeInfo casts to fail" <Variadic_member@pathlink.com> wrote in message news:dd60j3$10ki$1@digitaldaemon.com...
>> Has this been reported yet?  This happens with DMD 0.129 (and possibly
>> earlier
>> versions as well).
>>
>> # void main(){
>> # bit isArray(...){
>> # return cast(TypeInfo_Array)_arguments[0] !is null;
>> # }
>> # char[] foobar;
>> # assert(isArray(foobar));
>> # }
>>
>> The above fails the assert since the cast from _arguments[0] to
>> TypeInfo_Array
>> returns null.  This only fails with variadic functions: casting from
>> typeid()
>> works fine, even in templates.
>>
>> - EricAnderton at yahoo
>
>I couldn't get typeid(char[]) to cast to TypeInfo_Array - are you sure you were able to? Note if you look at src/phobos/std/typeinfo/ti_Aa.d is says char[]'s typeinfo subclasses TypeInfo not TypeInfo_Array.

The following does work:

# assert(cast(TypeInfo_Array)typeid(char[]) !is null);

It just seem so oddly inconsistent, especially since TypeInfo_Aa does in fact inherit from TypeInfo.

- EricAnderton at yahoo
August 08, 2005
>>I couldn't get typeid(char[]) to cast to TypeInfo_Array - are you sure you were able to? Note if you look at src/phobos/std/typeinfo/ti_Aa.d is says char[]'s typeinfo subclasses TypeInfo not TypeInfo_Array.
>
> The following does work:
>
> # assert(cast(TypeInfo_Array)typeid(char[]) !is null);

Interesting. I tried
    TypeInfo ti = typeid(char[]);
    assert( cast(TypeInfo_Array)ti !is null );
and it fails so it looks like typeid is "returning" void* or something.
Looks like a bug.


August 08, 2005
In article <dd7nr4$2g6i$1@digitaldaemon.com>, Ben Hinkle says...
>
>>>I couldn't get typeid(char[]) to cast to TypeInfo_Array - are you sure you were able to? Note if you look at src/phobos/std/typeinfo/ti_Aa.d is says char[]'s typeinfo subclasses TypeInfo not TypeInfo_Array.
>>
>> The following does work:
>>
>> # assert(cast(TypeInfo_Array)typeid(char[]) !is null);
>
>Interesting. I tried
>    TypeInfo ti = typeid(char[]);
>    assert( cast(TypeInfo_Array)ti !is null );
>and it fails so it looks like typeid is "returning" void* or something. Looks like a bug.
>

Yikes, now that's screwed up. I wonder if the TypeInfo's TypeInfo is what's broken?

- EricAnderton at yahoo
August 09, 2005
Ben Hinkle schrieb:

> "Variadic functions cause TypeInfo casts to fail" <Variadic_member@pathlink.com> wrote in message news:dd60j3$10ki$1@digitaldaemon.com...
> 
>> Has this been reported yet?  This happens with DMD 0.129 (and
>> possibly earlier versions as well).
>> 
>># void main(){
>># bit isArray(...){
>># return cast(TypeInfo_Array)_arguments[0] !is null;
>># }
>># char[] foobar;
>># assert(isArray(foobar));
>># }
>>
>> The above fails the assert since the cast from _arguments[0] to TypeInfo_Array returns null.  This only fails with variadic functions: casting from typeid() works fine, even in templates.
>> 
>> - EricAnderton at yahoo
> 
> 
> I couldn't get typeid(char[]) to cast to TypeInfo_Array - are you sure you were able to? Note if you look at src/phobos/std/typeinfo/ti_Aa.d is says char[]'s typeinfo subclasses TypeInfo not TypeInfo_Array.

Known Issue:
http://dstress.kuehne.cn/run/typeid_62.d

Thomas