home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / gnu / g / bug / 2316 < prev    next >
Encoding:
Text File  |  1993-01-23  |  2.6 KB  |  137 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!cs.wisc.edu!solomon
  2. From: solomon@cs.wisc.edu (Marvin Solomon)
  3. Newsgroups: gnu.g++.bug
  4. Subject: failure to munge template function name
  5. Date: 22 Jan 1993 21:47:04 -0500
  6. Organization: GNUs Not Usenet
  7. Lines: 124
  8. Sender: daemon@cis.ohio-state.edu
  9. Approved: bug-g++@prep.ai.mit.edu
  10. Distribution: gnu
  11. Message-ID: <9301222119.AA17515@gjetost.cs.wisc.edu>
  12.  
  13. // Problem with template functions in  g++ version 2.3.3
  14. // The compiler appears to be forgetting to munge the names of the functions
  15. // it generates for version of g (they are both called "g").  Needless to say,
  16. // the assembler is not very happy about it.  Under Ultrix, the message is
  17. //
  18. // as0: Error: bug3.c, line 10: .ent must precede the definition of the symbol g
  19. // as0: Error: bug3.c, line 10: Conflicting definition of symbol g
  20. //
  21. // (twice).  The generated assembly code is reproduced below.  Note the
  22. // two copies of "g": one that calls O__Fc and one that calls O__Fi.
  23.  
  24. void O(char);
  25. void O(int);
  26.  
  27. template <class Arg>
  28. class Template {
  29. public:
  30.     Arg i;
  31. };
  32.  
  33. template <class Arg> void g(Template<Arg> &x) { O(x.i); }
  34.  
  35. void f() {
  36.     Template<int> ti;
  37.     Template<char> tc;
  38.     g(ti);
  39.     g(tc);
  40. }
  41.  
  42. /*
  43.     .file    1 "bug3.c"
  44.  
  45.  # GNU C++ 2.3.3 [AL 1.1, MM 33] DECstation running ultrix compiled by GNU C
  46.  
  47.  # Cc1 defaults:
  48.  
  49.  # Cc1 arguments (-G value = 8, Cpu = default, ISA = 1):
  50.  # -quiet -dumpbase -o
  51.  
  52. gcc2_compiled.:
  53.     .text
  54.     .align    2
  55.     .globl    f__Fv
  56.  
  57.     .loc    1 22
  58.     .ent    f__Fv
  59. f__Fv:
  60.     .frame    $fp,32,$31        # vars= 8, regs= 2/0, args = 16, extra= 0
  61.     .mask    0xc0000000,-4
  62.     .fmask    0x00000000,0
  63.     subu    $sp,$sp,32
  64.     sw    $31,28($sp)
  65.     sw    $fp,24($sp)
  66.     move    $fp,$sp
  67.     addu    $4,$fp,16
  68.     jal    g
  69.     addu    $2,$fp,20
  70.     move    $4,$2
  71.     jal    g
  72.     j    $L2
  73.     j    $L1
  74. $L2:
  75. $L1:
  76.     move    $sp,$fp            # sp not trusted here
  77.     lw    $31,28($sp)
  78.     lw    $fp,24($sp)
  79.     addu    $sp,$sp,32
  80.     j    $31
  81.     .end    f__Fv
  82.     .align    2
  83.  
  84.     .loc    1 20
  85.     .ent    g
  86. g:
  87.     .frame    $fp,24,$31        # vars= 0, regs= 2/0, args = 16, extra= 0
  88.     .mask    0xc0000000,-4
  89.     .fmask    0x00000000,0
  90.     subu    $sp,$sp,24
  91.     sw    $31,20($sp)
  92.     sw    $fp,16($sp)
  93.     move    $fp,$sp
  94.     sw    $4,24($fp)
  95.     lw    $2,24($fp)
  96.     lb    $3,0($2)
  97.     move    $4,$3
  98.     jal    O__Fc
  99.     j    $L4
  100.     j    $L3
  101. $L4:
  102. $L3:
  103.     move    $sp,$fp            # sp not trusted here
  104.     lw    $31,20($sp)
  105.     lw    $fp,16($sp)
  106.     addu    $sp,$sp,24
  107.     j    $31
  108.     .end    g
  109.     .align    2
  110.  
  111.     .loc    1 20
  112.     .ent    g
  113. g:
  114.     .frame    $fp,24,$31        # vars= 0, regs= 2/0, args = 16, extra= 0
  115.     .mask    0xc0000000,-4
  116.     .fmask    0x00000000,0
  117.     subu    $sp,$sp,24
  118.     sw    $31,20($sp)
  119.     sw    $fp,16($sp)
  120.     move    $fp,$sp
  121.     sw    $4,24($fp)
  122.     lw    $2,24($fp)
  123.     lw    $4,0($2)
  124.     jal    O__Fi
  125.     j    $L6
  126.     j    $L5
  127. $L6:
  128. $L5:
  129.     move    $sp,$fp            # sp not trusted here
  130.     lw    $31,20($sp)
  131.     lw    $fp,16($sp)
  132.     addu    $sp,$sp,24
  133.     j    $31
  134.     .end    g
  135. */
  136.  
  137.