digitalmars.D - bogus cast errors?
- Kris (16/16) Apr 08 2005 void main()
- Walter (1/1) Apr 09 2005 Yeah, that ain't right. I'll fix it.
- Thomas Kuehne (13/29) Apr 09 2005 -----BEGIN PGP SIGNED MESSAGE-----
void main()
{
char[] s;
char[] t;
if (true)
s = null;
s = (true) ? null : t;
}
"test.d(8): cannot implicitly convert expression (1 ? null : cast(void*)(t))
of type void* to char[]"
You could be forgiven for thinking the error is talking about 't'. But it's
actually talking about the assignment of null instead. This works as
expected:
s = (true) ? cast(char[]) null : t;
But you've got to explicitly cast the null. Yet, the "more traditional"
assignment, on line 7, is accepted without error. What's the deal here?
Apr 08 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Kris schrieb am Fri, 8 Apr 2005 22:33:34 -0700:
void main()
{
char[] s;
char[] t;
if (true)
s = null;
s = (true) ? null : t;
}
"test.d(8): cannot implicitly convert expression (1 ? null : cast(void*)(t))
of type void* to char[]"
You could be forgiven for thinking the error is talking about 't'. But it's
actually talking about the assignment of null instead. This works as
expected:
s = (true) ? cast(char[]) null : t;
But you've got to explicitly cast the null. Yet, the "more traditional"
assignment, on line 7, is accepted without error. What's the deal here?
Added to DStress as
http://dstress.kuehne.cn/run/cast_25.d
http://dstress.kuehne.cn/run/cast_26.d
http://dstress.kuehne.cn/run/cast_27.d
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFCV5xW3w+/yD4P9tIRAlafAKCYGMCbyX7qACkUBrK0AHbGZOVn8QCfUn3S
B3KhsIqYn8/cBj3jgETW32w=
=kslh
-----END PGP SIGNATURE-----
Apr 09 2005









"Walter" <newshound digitalmars.com> 