Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
August 07, 2005 pragma | ||||
---|---|---|---|---|
| ||||
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 Variadic functions cause TypeInfo casts to fail says... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Variadic functions cause TypeInfo casts to fail | 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 Re: pragma | ||||
---|---|---|---|---|
| ||||
Posted in reply to Variadic functions cause TypeInfo casts to fail | "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 Re: Variadic functions cause TypeInfo casts to fail | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | 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 Re: Variadic functions cause TypeInfo casts to fail | ||||
---|---|---|---|---|
| ||||
Posted in reply to pragma | >>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 Re: Variadic functions cause TypeInfo casts to fail | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | 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 Re: pragma | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle Attachments: | 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 |
Copyright © 1999-2021 by the D Language Foundation