www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - pragma

reply Variadic functions cause TypeInfo casts to fail <Variadic_member pathlink.com> writes:
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
Aug 07 2005
next sibling parent pragma <pragma_member pathlink.com> writes:
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
Aug 07 2005
prev sibling parent reply "Ben Hinkle" <ben.hinkle gmail.com> writes:
"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.
Aug 07 2005
next sibling parent reply pragma <pragma_member pathlink.com> writes:
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
Aug 07 2005
parent reply "Ben Hinkle" <bhinkle mathworks.com> writes:
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.
Aug 08 2005
parent pragma <pragma_member pathlink.com> writes:
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
Aug 08 2005
prev sibling parent =?ISO-8859-1?Q?Thomas_K=FChne?= <thomas-dloop kuehne.THISISSPAM.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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 -----BEGIN PGP SIGNATURE----- iD8DBQFC+IX03w+/yD4P9tIRAkm1AJ9nBmwpKb8Un2T7bS2Pk0igxiw7JgCgiBVe CVmYgxjQ4s1u0IrIGezi8Vg= =SNO1 -----END PGP SIGNATURE-----
Aug 09 2005