🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1305

gcc (C++) 2.3.2 generates bad assembly language output (redefined symbol)

#1305
From: Thomas M. Breuel
Date: Mon, 04 Jan 1993 16:31
59 lines
2308 bytes
[sorry for the duplicate posting, but this message hasn't made it to
gnu.g++.bug under the correct "Subject:" line apparently due to some
gateway problems at GNU]

gcc -v -c foo.cc
Reading specs from /sym/gnu/lib/gcc-lib/sparc-sun-sunos4.1/2.3.2/specs
gcc version 2.3.2
 /sym/gnu/lib/gcc-lib/sparc-sun-sunos4.1/2.3.2/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.cc /local/tmp/cca11717.i
GNU CPP version 2.3.2 (sparc)
 /sym/gnu/lib/gcc-lib/sparc-sun-sunos4.1/2.3.2/cc1plus /local/tmp/cca11717.i -quiet -dumpbase foo.cc -version -o /local/tmp/cca11717.s
GNU C++ version 2.3.2 (sparc) compiled by GNU C version 2.3.2.
 as -o foo.o /local/tmp/cca11717.s
as: "/local/tmp/cca11717.s", line 96: error: redefinition of symbol "_lookup"
gcc: foo.o: No such file or directory

== foo.cc ======================================================
#include <std.h>

template <class Y>
struct NameValuePair {
	char *name;
	Y y;
};

template <class Y>
inline Y lookup(NameValuePair<Y> *data,char *name) {
	while(data->name) {
		if(!strcmp(data->name,name)) return data->y;
		data++;
	}
	abort();
	return data->y;		// to keep GCC happy
}

template <class T>
void swap(T &x,T &y) {
	T temp = x;
	x = y;
	y = temp;
}

typedef char (*canonicalizer)(char &,float *);

NameValuePair<canonicalizer> canonicalizers[] = {
	{0,0}
};

typedef float (*extractor)(float &image,float g=2.0);

NameValuePair<extractor> extractors[] = {
	{0,0}
};

void foo() {
	canonicalizer canonicalize = lookup(canonicalizers,(char*)"foo");
	extractor extract = lookup(extractors,(char*)"bar");
}

================================================================
Technical Details
Message-ID: <TMB.93Jan4113159@arolla.idiap.ch>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!arolla.idiap.ch!tmb

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!arolla.idiap.ch!tmb
From: tmb@arolla.idiap.ch (Thomas M. Breuel)
Subject: gcc (C++) 2.3.2 generates bad assembly language output (redefined symbol)
Message-ID: <TMB.93Jan4113159@arolla.idiap.ch>
Sender: gnulists@ai.mit.edu
Reply-To: tmb@idiap.ch
Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
 Perceptive)
Distribution: gnu
Date: Mon, 4 Jan 1993 16:31:59 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 63