http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46527

           Summary: Member of template class gets wrong debug location
                    when template (but not member) is used before member
                    is defined
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: jyass...@gcc.gnu.org


The debug information should locate Vector4<double>::defined_later() at its
definition (in good.h), not its declaration (in bad.h). This causes problems
for Gold's --detect-odr-violations flag.

Test case:

$ cat test.cc
template <typename VType> struct Vector4 {
# 1 "bad.h" 1
  double defined_later();
# 42 "good.h"
};
struct WrapperStruct {
  Vector4<double> ClassInstantiated;
};
template <typename VType> double Vector4<VType>::defined_later() {
  return 1;
}
void InstantiateMethod() {
  Vector4<double>().defined_later();
}

$ ~/gcc/trunk/install/bin/g++ -c -g test.cc -o test.o

$ objdump -dCl test.o
...
0000000000000000 <Vector4<double>::defined_later()>:
_ZN7Vector4IdE13defined_laterEv():
/home/jyasskin/tmp/bad.h:1
   0:   55                      push   %rbp
   1:   48 89 e5                mov    %rsp,%rbp
   4:   48 89 7d f8             mov    %rdi,-0x8(%rbp)
/home/jyasskin/tmp/good.h:47
   8:   48 b8 00 00 00 00 00    mov    $0x3ff0000000000000,%rax
   f:   00 f0 3f 
  12:   48 89 45 f0             mov    %rax,-0x10(%rbp)
  16:   f2 0f 10 45 f0          movsd  -0x10(%rbp),%xmm0
/home/jyasskin/tmp/good.h:48
  1b:   5d                      pop    %rbp
  1c:   c3                      retq

Reply via email to