libstdc++/3377: missing std::__cmath_power<double>(double,unsigned)

garloff@suse.de garloff@suse.de
Fri Jun 22 11:06:00 GMT 2001


>Number:         3377
>Category:       libstdc++
>Synopsis:       missing std::__cmath_power<double>(double,unsigned)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 22 11:06:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Kurt Garloff
>Release:        3.0.1 20010620 (prerelease)
>Organization:
TU/e, SuSE
>Environment:
System: Linux gum07.etpnet.phys.tue.nl 2.4.0-test13-pre3 #18 Sat Dec 23 00:22:26 CET 2000 i686 unknown
Architecture: i686
Libraries: glibc-2.1.3
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../configure --with-gcc-version-trigger=/usr/src/gcc-2.96/gcc/version.c --host=i686-pc-linux-gnu --prefix=/usr/src/i686-pc-gcc297 --enable-shared --with-gnu-as --with-gnu-ld --enable-haifa --with-system-zlib : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured) 
>Description:
	http://gcc.gnu.org/ml/gcc/2001-06/msg01190.html
	compiling my templated C++ numeric library with gcc-3.0.0, I use
	-fno-implicit-templates to prevent multiple instantiations and explicitly
	instantiate all the templates that are supposed to be in the library.
	I stumbled across this:
	../lina/bin-ix86/libtbcidouble.so: undefined reference to double
	std::__cmath_power<double>(double, unsigned)' I'm rather sure this
	is a bug: -fno-implicit-templates is not supposed to
	change the underlying C++ std library, is it?
	
	The compiler probably can't just ignore the flag for included C++ std
	headers, but then, those symbols should be (weakly) present in libstdc++.so.
	At least for the templates only used internally.
>How-To-Repeat:
	Compile this program with -fno-inline-functions
/** cmath_pow.cc
 * 
 * Trying to reproduce linking  errors for
 * double std::__cmath_power<double>(double, unsigned)
 * in gcc-3.0.0, if -fno=implicit-templates is used.
 * The flag also affects the internally used (invisible) templates 
 * from the C++ std library :-( and at least std::__cmath_power
 * is missing from libstdc++.so.
 *
 * (c) Kurt Garloff, garloff@suse.de, 2001-06-20, GNU GPL
 * 
 * Compile with g++ -o cmath_pow cmath_pow.cc -fno-implicit-templates
 * 
 */

#include <cstdlib>
#include <cstdio>
#include <cmath>

namespace testns {
template <typename T>
double our_pow (const T v, const int pw)
{
	return std::pow ((double)v, pw);
};
};


// Explicitly instantiate (needed because -fno-implicit-templates)
namespace testns {
template double our_pow<long> (const long, const int);
};

int main (int argc, char* argv[])
{
	long int arg = 2; int pw = 4;
	if (argc >= 2)
		arg = std::atol (argv[1]);
	if (argc >= 3)
		pw = std::atol (argv[2]);
	long int res = (long int) testns::our_pow (arg, pw);
	std::printf ("%li\n", res);
	return 0;
}

// The problem ...
#ifdef WORKAROUND
template double std::__cmath_power<double>(double, unsigned);
#endif

>Fix:
	Workaround:
	Add -DWORKAROUND to the compiler switches.
	
	Fix:
	Add the needed std::__cmath_power<*>(*,unsigned)
	to libstdc++.
	
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list