i386-cygwin32: C++ template codegen bug

Mumit Khan khan@xraylith.wisc.edu
Tue Oct 28 08:46:00 GMT 1997


Mumit Khan <khan@cygnus.com> writes:
> 
> While trying compile some local (simple) code for a i386-cygwin32, I came
> across some bizarre template linking errors; after a bit of investigation
> I believe it has to do with gcc *not* generating "weak" symbols, instead
> creating out of line copies of inline functions with extern linkage. 
> 
> I'm attaching the example code (< 10 lines of code in two different
> files). Must use -g to show the problem. 

I'm uncertain as to whether it's a codegen bug or assembler bug. I'm
using gas-971023 snapshot.

  #include <complex>

  static complex<double> c1;
  double x1 = arg(c1);		// << Let's take this for example

egcs generates the following code (with -g):

  [ ... showing only 'double arg<double> (complex<double>&)' ... ]

  LFE4:
	  .section .text$arg__H1Zd_RCt7complex1ZX01_X01,"x"
	  .linkonce discard
	  .align 4
  .globl _arg__H1Zd_RCt7complex1ZX01_X01
  _arg__H1Zd_RCt7complex1ZX01_X01:

  [ ... rest snipped ... ]

Note that egcs generates a '.text$SYMBOL' section and gives it the
".linkonce discard" attribute correctly. PE linker is supposed to
pick one of the sections at link time and discard the rest in various
translation units if I understand this correctly. 

After assembly, I get (showing only relevant lines):

  00000000 t double .text$arg<double>(complex<double> const &)
  00000000 T double arg<double>(complex<double> const &)

Now should egcs also describe is global? If so, shouldn't the linkonce
directive override global during assembly?

If I manually remove the ".globl" for the offending symbols, I get a
clean link. Don't know if that's just by chance of course.

Help!

Regards,
Mumit -- khan@xraylith.wisc.edu
http://www.xraylith.wisc.edu/~khan/



More information about the Gcc-bugs mailing list