www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [variadic] not typesafe

reply Manfred Nowak <svv1999 hotmail.com> writes:
<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
parent Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----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