home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / gnu / gcc / bug / 2818 < prev    next >
Encoding:
Text File  |  1992-11-21  |  2.1 KB  |  68 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cs.berkeley.edu!sethg
  3. From: sethg@cs.berkeley.edu (Seth C. Goldstein)
  4. Subject: gcc 2.3.1 bug with function templates (multiple definitions)
  5. Message-ID: <9211220021.AA21710@boing.CS.Berkeley.EDU>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Sat, 21 Nov 1992 08:21:08 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 55
  12.  
  13. Machine:    sparc
  14. Version:    gcc version 2.3.1
  15. OS:        SunOS Release 4.1.2
  16. problem:    If more than one  use of a function, which is defined
  17.         with a template, occurs in a file, the assembler claims
  18.         that the function is defined more than once.
  19.  
  20. sample code:
  21. /////////////////////////////////////////////////////////// start
  22. int *packAddress(void);
  23. void packDone(int);
  24. #define intsIn(T)    ((sizeof(T)+(sizeof(T)-1))/sizeof(int))
  25.  
  26. int i;
  27. double d;
  28. int j;
  29.  
  30. template<class T>
  31. void
  32. pack(T& data)
  33. {
  34.     T *p = (T *)packAddress();
  35.  
  36.     *p = data;
  37.     packDone(intsIn(T));
  38. }
  39.  
  40. foo()
  41. {
  42.     pack(i);
  43.     pack(d);
  44.     pack(j);
  45. }
  46. /////////////////////////////////////////////////////////// end
  47. sample compilation:
  48. /////////////////////////////////////////////////////////// start
  49. gcc-2.3.1 -v -o foo foo.C
  50. Reading specs from /usr/sww/lib/gcc-lib/sparc-sun-sunos4.1/2.3.1/specs
  51. gcc version 2.3.1
  52.  /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
  53. GNU CPP version 2.3.1 (sparc)
  54.  /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
  55. GNU C++ version 2.3.1 (sparc) compiled by GNU C version 2.3.1.
  56. foo.C: In function `int  foo ()':
  57. foo.C:24: warning: control reaches end of non-void function
  58.  as -o /usr/tmp/cca217001.o /usr/tmp/cca21700.s
  59. as: "/usr/tmp/cca21700.s", line 57: error: redefinition of symbol "_pack"
  60. gcc-2.3.1: /usr/tmp/cca217001.o: No such file or directory
  61. /////////////////////////////////////////////////////////// end
  62.  
  63. -seth
  64.  
  65. p.s. Am I sending these reports to the correct place?
  66.  
  67.  
  68.