public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/46527] New: Member of template class gets wrong debug location when template (but not member) is used before member is defined
@ 2010-11-17 23:00 jyasskin at gcc dot gnu.org
  2010-11-20  1:05 ` [Bug c++/46527] " jyasskin at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jyasskin at gcc dot gnu.org @ 2010-11-17 23:00 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: jyasskin@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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/46527] Member of template class gets wrong debug location when template (but not member) is used before member is defined
  2010-11-17 23:00 [Bug c++/46527] New: Member of template class gets wrong debug location when template (but not member) is used before member is defined jyasskin at gcc dot gnu.org
@ 2010-11-20  1:05 ` jyasskin at gcc dot gnu.org
  2010-11-24  0:48 ` jyasskin at gcc dot gnu.org
  2010-11-24 23:18 ` jyasskin at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jyasskin at gcc dot gnu.org @ 2010-11-20  1:05 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey Yasskin <jyasskin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2010.11.20 00:57:42
         AssignedTo|unassigned at gcc dot       |jyasskin at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #1 from Jeffrey Yasskin <jyasskin at gcc dot gnu.org> 2010-11-20 00:57:42 UTC ---
Created attachment 22465
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22465
Possible fix

Here's a possible patch. I'll add a test and run the test suite and then send
it to gcc-patches. Corrections are welcome in the mean time.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/46527] Member of template class gets wrong debug location when template (but not member) is used before member is defined
  2010-11-17 23:00 [Bug c++/46527] New: Member of template class gets wrong debug location when template (but not member) is used before member is defined jyasskin at gcc dot gnu.org
  2010-11-20  1:05 ` [Bug c++/46527] " jyasskin at gcc dot gnu.org
@ 2010-11-24  0:48 ` jyasskin at gcc dot gnu.org
  2010-11-24 23:18 ` jyasskin at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jyasskin at gcc dot gnu.org @ 2010-11-24  0:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jeffrey Yasskin <jyasskin at gcc dot gnu.org> 2010-11-24 00:25:01 UTC ---
Author: jyasskin
Date: Wed Nov 24 00:24:54 2010
New Revision: 167104

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=167104
Log:
Propagate the source location from a template function's definition to
any already-instantiated declarations.

    PR c++/46527
    * gcc/cp/pt.c (instantiate_decl): Propagate the template's
    location to its instance.
    * gcc/testsuite/g++.dg/debug/dwarf2/pr46527.C: New test.


Added:
    trunk/gcc/testsuite/g++.dg/debug/dwarf2/pr46527.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/46527] Member of template class gets wrong debug location when template (but not member) is used before member is defined
  2010-11-17 23:00 [Bug c++/46527] New: Member of template class gets wrong debug location when template (but not member) is used before member is defined jyasskin at gcc dot gnu.org
  2010-11-20  1:05 ` [Bug c++/46527] " jyasskin at gcc dot gnu.org
  2010-11-24  0:48 ` jyasskin at gcc dot gnu.org
@ 2010-11-24 23:18 ` jyasskin at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jyasskin at gcc dot gnu.org @ 2010-11-24 23:18 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey Yasskin <jyasskin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #3 from Jeffrey Yasskin <jyasskin at gcc dot gnu.org> 2010-11-24 22:57:08 UTC ---
Fixed by r167104.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-11-24 22:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-17 23:00 [Bug c++/46527] New: Member of template class gets wrong debug location when template (but not member) is used before member is defined jyasskin at gcc dot gnu.org
2010-11-20  1:05 ` [Bug c++/46527] " jyasskin at gcc dot gnu.org
2010-11-24  0:48 ` jyasskin at gcc dot gnu.org
2010-11-24 23:18 ` jyasskin at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).