Package: g++-4.2
Version: 4.2.2-4
Severity: normal

If a template is explicitly specialized, it is by default extern, even if its corresponding generic template is static. The only way to make it static is by explicitly marking the specialization static. However, g++-4.3 does not allow marking the specialization static, because it properly imports the storage class from the generic template.

gcc-4.2 should do what gcc-4.3 does, but it probably should not reject the explicit use of static, for backward compatibility purposes.

lakeview ok % gcc-4.2 -c static-template.cc lakeview ok % nm -aC static-template.o | grep size
0000000000000010 t int size<float>(float*)
0000000000000000 T int size<int>(int*)
lakeview ok % gcc-4.2 -DUSE_STATIC -c static-template.cc
lakeview ok % nm -aC static-template.o | grep size 0000000000000010 t int size<float>(float*)
0000000000000000 t int size<int>(int*)
lakeview ok % gcc-4.3 -c static-template.cc lakeview ok % nm -aC static-template.o | grep size
0000000000000010 t int size<float>(float*)
0000000000000000 t int size<int>(int*)
lakeview ok % gcc-4.3 -DUSE_STATIC -c static-template.cc
static-template.cc:14: error: explicit template specialization cannot have a 
storage class


-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.24-rc4 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL 
set to en_US.UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages g++-4.2 depends on:
ii  gcc-4.2                       4.2.2-4    The GNU C compiler
ii gcc-4.2-base 4.2.2-4 The GNU Compiler Collection (base ii libc6 2.7-4 GNU C Library: Shared libraries
ii  libstdc++6-4.2-dev            4.2.2-4    The GNU Standard C++ Library v3 (d

g++-4.2 recommends no packages.

-- no debconf information

--
brian m. carlson / brian with sandals: Houston, Texas, US
+1 713 440 7475 | http://crustytoothpaste.ath.cx/~bmc | My opinion only
a typesetting engine: http://crustytoothpaste.ath.cx/~bmc/code/thwack
OpenPGP: RSA v4 4096b 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
template<class T>
static int size(T *obj)
{
	return obj != 0;
}

template<>
#ifdef USE_STATIC
static
#endif
int size(int *obj)
{
	return *obj;
}

bool do_func()
{
	int arr[] = { 0 };
	float *p = 0;

	return size(arr) && size(p);
};

Attachment: signature.asc
Description: Digital signature

Reply via email to