Bug 11961 - Wrong type reported by gdb
Summary: Wrong type reported by gdb
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.1
: P2 normal
Target Milestone: 7.3
Assignee: Tom Tromey
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-31 17:05 UTC by Andre'
Modified: 2010-08-31 20:05 UTC (History)
1 user (show)

See Also:
Host: i486-linux-gnu
Target: i486-linux-gnu
Build: i486-linux-gnu
Last reconfirmed: 2010-08-31 19:40:40


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andre' 2010-08-31 17:05:38 UTC
This is a somewhat curious issue as one needs fairly recent gcc (>= 4.5) _and_
gdb ( > 2010-07-29 ) to reproduce.


----------------- snip -----------------
#!/bin/sh

# To reproduce:
#   - use g++ 4.5 or 4.6 (but not 4.4)
#   - use gdb from CVS from 2010-07-29 or newer

echo "

template<typename _ForwardIterator>
void x(_ForwardIterator __first)
{
}

template<typename T>
struct vector
{
    T* _M_start;
    vector() { x(_M_start); }
};

struct foo {};

int main()
{
    vector<foo> flist;
    foo *f = new foo;
}
" > foo.cpp

CXX=/usr/local/bin/i686-pc-linux-gnu-g++-4.5.0
CXX=/usr/bin/g++
CXX=/usr/local/bin/i686-pc-linux-gnu-g++-4.6.0

${CXX} -g foo.cpp -o foo

GDB=~/bin/gdb-7.1   # works
GDB=~/bin/gdb-7.0   # works
GDB=~/debugger/fsf-git/gdb/gdb  # "fails"

${GDB} -ex 'set confirm off' \
    -ex 'b main' -ex 'run' -ex 'p f' -ex 'q'\
    ./foo


# GNU gdb (GDB) 7.2.50.20100728-cvs
# [...]
# Breakpoint 1 at 0x80486d2: file foo.cpp, line 18.
# Breakpoint 1, main () at foo.cpp:18
# #18          foo *f = new foo;
# $1 = (_ForwardIterator) 0x402b8ff4
----------------- snip -----------------


The type 'ForwardIterator' is wrong, should be  (foo *)
Comment 1 Tom Tromey 2010-08-31 19:40:40 UTC
Testing a fix.
Comment 2 Sourceware Commits 2010-08-31 20:03:43 UTC
Subject: Bug 11961

CVSROOT:	/cvs/src
Module name:	src
Changes by:	tromey@sourceware.org	2010-08-31 20:03:22

Modified files:
	gdb            : ChangeLog dwarf2read.c 

Log message:
	PR c++/11961:
	* dwarf2read.c (new_symbol_full) <DW_TAG_template_type_param>:
	Don't set TYPE_NAME on the type.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.12131&r2=1.12132
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/dwarf2read.c.diff?cvsroot=src&r1=1.448&r2=1.449

Comment 3 Tom Tromey 2010-08-31 20:05:01 UTC
Fix checked in.