public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/10591] New: Print shows nonsenses for templated structs passed as function parameters (Linux, c++)
@ 2009-09-02 20:28 dolik dot rce at seznam dot cz
2009-09-02 22:29 ` [Bug c++/10591] " keiths at redhat dot com
0 siblings, 1 reply; 2+ messages in thread
From: dolik dot rce at seznam dot cz @ 2009-09-02 20:28 UTC (permalink / raw)
To: gdb-prs
Description:
------------
If templated struct containing specialized constructors is passed as a function
parameter, print command in gdb shows wrong values of it's members inside this
function.
Testcase:
---------
template <class T>
struct TestStruct{
T x;
TestStruct(T x) : x(x){}
TestStruct(const TestStruct<int>& pt) : x((T)pt.x) {}
};
void somefunction(TestStruct<int> p){
TestStruct<double> pt(p);
pt.x=pt.x/10.0;
}
int main(){
TestStruct<int> p(10);
somefunction(p);
return 0;
}
How to reproduce:
-----------------
Compile the above mentioned testcase (g++-4.3 -ggdb -o /tmp/test /tmp/test.cpp)
and run in gdb (gdb /tmp/test) like this:
(gdb) break somefunction(TestStruct<int>)
Breakpoint 1 at 0x80483ea: file /tmp/test.cpp, line 9.
(gdb) run
Starting program: /tmp/test
Breakpoint 1, somefunction (p={x = -1074851108})
at /tmp/test.cpp:9
9 TestStruct<double> pt(p);
(gdb) print p
$1 = {x = -1074851108}
(gdb) next
10 pt.x=pt.x/10.0;
(gdb) print p
$2 = {x = -1074851108}
Expected result is {x = 10}.
Environment:
------------
jd@jdl~: gdb -v
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
jd@jdl~: uname -a
Linux jdl1 2.6.28-15-generic #49-Ubuntu SMP Tue Aug 18 18:40:08 UTC 2009 i686
GNU/Linux
jd@jdl~: g++-4.3 -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.3-5ubuntu4' -
-with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-
languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-
system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-
threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --
program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-
gc --enable-mpfr --enable-targets=all --with-tune=generic --enable-
checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-
linux-gnu
Thread model: posix
gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4)
--
Summary: Print shows nonsenses for templated structs passed as
function parameters (Linux, c++)
Product: gdb
Version: 6.8
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at sourceware dot org
ReportedBy: dolik dot rce at seznam dot cz
CC: gdb-prs at sourceware dot org
http://sourceware.org/bugzilla/show_bug.cgi?id=10591
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-09-02 22:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-02 20:28 [Bug c++/10591] New: Print shows nonsenses for templated structs passed as function parameters (Linux, c++) dolik dot rce at seznam dot cz
2009-09-02 22:29 ` [Bug c++/10591] " keiths at redhat dot com
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).