This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
2.96: templated varargs
- To: gcc-bugs at gcc dot gnu dot org
- Subject: 2.96: templated varargs
- From: Kurt Garloff <kurt at garloff dot de>
- Date: Mon, 10 Jan 2000 20:31:28 +0100
- Cc: "Jan van Dijk" <jan at etpmod dot phys dot tue dot nl>
- Organization: TUE/NL, SuSE/FRG
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