This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

2.96: templated varargs


Hi,

does gcc-2.96 remove support for variadic argument lists in combination with
templates? Why? Does the C++ draft standard say so?

garloff@etpvis:~/gum/testsuite/compiler > g++ -O2 templvararg.cpp -DWITHOUT_TEMPLATES -o templvararg
garloff@etpvis:~/gum/testsuite/compiler > ./templvararg
 Testing with templates DISabled
 1       2       3
garloff@etpvis:~/gum/testsuite/compiler > g++ -O2 templvararg.cpp -o templvararg 
 templvararg.cpp: In function void PrintArgs (Type, ...)':
 templvararg.cpp:36: invalid use of template type parameter

Compiler:
garloff@etpvis:~/gum/testsuite/compiler > g++ -v
 Reading specs from /usr/local/egcs-2.96/lib/gcc-lib/i686-pc-linux-gnu/2.96/specs
 gcc version 2.96 20000110 (experimental)

With egcs-1.1.2, the code compiles and produces the expected result.

System is a SuSE-Linux 6.2 iX86 (glibc-2.1.1, Linux-2.2.13). 
Sourcecode attached. 


PS: Please Cc: answers to me, I'm not currently subscribed to gcc-bugs.
-- 
Kurt Garloff                 <kurt@garloff.de>		    [Eindhoven, NL]
Physics: Plasma simulations  <k.garloff@phys.tue.nl>	 [TU Eindhoven, NL]
Linux: SCSI, Security        <garloff@suse.de>	      [SuSE Nuernberg, FRG]
(See mail header or public servers for PGP2[RSA] and GPG[DSA] public keys.)
/* templvararg.cpp */
/*
 * Testcase for the compiler to handle varargs with templated
 * types. Should result in problems for char or float values,
 * because of the std promotion taking place, but be compilable
 * and functional, IMHO. Kurt Garloff <kurt@garloff.de>, 1/2000.
 * Testcase by Jan van Dijk <jan@etpmod.phys.tue.nl>, 1/2000.
 * Copyright: GNU GPL
 */

#include <iostream>
#include <stdarg.h>

// if you don't enable the next line, this program won't compile
// with gcc 2.96 (snapshot 20000103), ...
//#define WITHOUT_TEMPLATES

#define TestType double

#ifdef WITHOUT_TEMPLATES
# define Type TestType
#else
 template <class Type>
#endif
void PrintArgs (Type somearg, ...)
{ 
	cout << "Testing with templates "
#ifndef WITHOUT_TEMPLATES		
		<< "ENabled" << endl;
#else
		<< "DISabled" << endl;
#endif
	va_list argp;
	va_start (argp, somearg);
	Type value;
	while ( ( value  = va_arg (argp, Type) ) > 0.0)
		cout << value << '\t';
	cout << endl;
	va_end (argp);
}

int main (void)
{
	TestType dummy = 0;
	/// termination criterium: value < 0
	PrintArgs (dummy, 1.0, 2.0, 3.0, -1.0);
	return 0;
}

PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]