home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky gnu.g++.help:1623 comp.lang.c++:18644
- Newsgroups: gnu.g++.help,comp.lang.c++
- Path: sparky!uunet!wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!idiap.CH!tmb
- From: tmb@idiap.CH (Thomas M. Breuel)
- Subject: gcc (C++) 2.3.2 generates bad assembly language output (redefined
- symbol)
- Message-ID: <9301021848.AA15972@idiap.ch>
- Sender: gnulists@ai.mit.edu
- Reply-To: tmb@idiap.ch
- Organization: Gatewayed from the GNU Project mailing list help-g++@prep.ai.mit.edu
- Date: Sat, 2 Jan 1993 20:48:51 GMT
- Lines: 56
-
- 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");
- }
-
- ================================================================
-
-