www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Typesafe variadic function typo...

reply "Unknown W. Brackets" <unknown simplemachines.org> writes:
I made a typo testing the new typesafe variadic functions, which crashed 
the compiler with this message:

test.d(8): function test2.test (int...) does not match argument types 
(int[])
Assertion failure: '0' on line 272 in file 'expression.c'

The code in question is:

void test(int i ...)
{
}

int main()
{
	const int[] i = [1];
	test(i);

	return 0;
}

The code is of course wrong, the first line should be:

void test(int[] i ...)

Or test should be called with exactly one int parameter - no more, no less.

But that doesn't mean a crash is in order ;).  Looking at the code, I 
would guess some errors for other cases of the switch would fix it.

-[Unknown]
Jun 11 2005
parent Thomas Kuehne <thomas-dloop kuehne.this-is-spam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Unknown W. Brackets schrieb am Sat, 11 Jun 2005 19:25:28 -0700:
 I made a typo testing the new typesafe variadic functions, which crashed 
 the compiler with this message:

 test.d(8): function test2.test (int...) does not match argument types 
 (int[])
 Assertion failure: '0' on line 272 in file 'expression.c'

 The code in question is:

 void test(int i ...)
 {
 }

 int main()
 {
 	const int[] i = [1];
 	test(i);

 	return 0;
 }

 The code is of course wrong, the first line should be:

 void test(int[] i ...)

 Or test should be called with exactly one int parameter - no more, no less.

 But that doesn't mean a crash is in order ;).  Looking at the code, I 
 would guess some errors for other cases of the switch would fix it.

Added to DStress as http://dstress.kuehne.cn/nocompile/v/variadic_argument_06_A.d http://dstress.kuehne.cn/nocompile/v/variadic_argument_06_B.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCs91+3w+/yD4P9tIRAjgZAJ911k148DDQgMbM71WuOIntBztP6gCgoAug 5rb/VzaittFxKvVJXMEuV1M= =Qp2j -----END PGP SIGNATURE-----
Jun 18 2005