🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Seth C. Goldstein Sat, 21 Nov 1992 08:21
gcc 2.3.1 bug with function templates (multiple definitions)
#1464
Author: Seth C. Goldstein
Date: Sat, 21 Nov 1992 08:21
53 lines
2201 bytes
Machine:	sparc
Version:	gcc version 2.3.1
OS:		SunOS Release 4.1.2
problem:	If more than one  use of a function, which is defined
		with a template, occurs in a file, the assembler claims
		that the function is defined more than once.

sample code:
/////////////////////////////////////////////////////////// start
int *packAddress(void);
void packDone(int);
#define intsIn(T)	((sizeof(T)+(sizeof(T)-1))/sizeof(int))

int i;
double d;
int j;

template<class T>
void
pack(T& data)
{
	T *p = (T *)packAddress();

	*p = data;
	packDone(intsIn(T));
}

foo()
{
	pack(i);
	pack(d);
	pack(j);
}
/////////////////////////////////////////////////////////// end
sample compilation:
/////////////////////////////////////////////////////////// start
gcc-2.3.1 -v -o foo foo.C
Reading specs from /usr/sww/lib/gcc-lib/sparc-sun-sunos4.1/2.3.1/specs
gcc version 2.3.1
 /usr/sww/lib/gcc-lib/sparc-sun-sunos4.1/2.3.1/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix foo.C /usr/tmp/cca21700.i
GNU CPP version 2.3.1 (sparc)
 /usr/sww/lib/gcc-lib/sparc-sun-sunos4.1/2.3.1/cc1plus /usr/tmp/cca21700.i -quiet -dumpbase foo.cc -version -o /usr/tmp/cca21700.s
GNU C++ version 2.3.1 (sparc) compiled by GNU C version 2.3.1.
foo.C: In function `int  foo ()':
foo.C:24: warning: control reaches end of non-void function
 as -o /usr/tmp/cca217001.o /usr/tmp/cca21700.s
as: "/usr/tmp/cca21700.s", line 57: error: redefinition of symbol "_pack"
gcc-2.3.1: /usr/tmp/cca217001.o: No such file or directory
/////////////////////////////////////////////////////////// end

-seth

p.s. Am I sending these reports to the correct place?
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads