digitalmars.D.bugs - [variadic] not typesafe
-
Manfred Nowak
(17/17)
Apr 20 2005
Thomas Kuehne (14/31) Apr 20 2005 -----BEGIN PGP SIGNED MESSAGE-----
<docs href="http://www.digitalmars.com/d/function.html#variadic> _arguments gives the number of arguments and the type of each, enabling the creation of typesafe variadic functions. </docs> But the assertion is not thrown here: <code> import std.stdio, std.stdarg; template t(T){ T t(...){ assert( _arguments[ 0] == typeid( T)); return va_arg!(T)(_argptr); } } void main(){ writefln( t!(int delegate())(delegate real(){ return 1.1L;})()); } </code>
Apr 20 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Manfred Nowak schrieb am Thu, 21 Apr 2005 01:08:09 +0000 (UTC):<docs href="http://www.digitalmars.com/d/function.html#variadic> _arguments gives the number of arguments and the type of each, enabling the creation of typesafe variadic functions. </docs> But the assertion is not thrown here: <code> import std.stdio, std.stdarg; template t(T){ T t(...){ assert( _arguments[ 0] == typeid( T)); return va_arg!(T)(_argptr); } } void main(){ writefln( t!(int delegate())(delegate real(){ return 1.1L;})()); } </code>Added to DStress as http://dstress.kuehne.cn/run/variadic_argument_04.d http://dstress.kuehne.cn/run/variadic_argument_05.d Thomas - - Fejagd, cut those Bugs! http://fejagd.kuehne.cn -----BEGIN PGP SIGNATURE----- iD8DBQFCZzzM3w+/yD4P9tIRAky9AJ9w0jOsYzOlG+iKchwADHQvmuv6dgCgytGj edhO0xrNYzzt444YZn6rWHk= =C+PZ -----END PGP SIGNATURE-----
Apr 20 2005