public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* c++/2567: Wrong representation of C++ structure with copy constructors passed as parameter
@ 2008-12-16 13:48 epsilon
  0 siblings, 0 replies; only message in thread
From: epsilon @ 2008-12-16 13:48 UTC (permalink / raw)
  To: gdb-gnats; +Cc: alex2001


>Number:         2567
>Category:       c++
>Synopsis:       Wrong representation of C++ structure with copy constructors passed as parameter
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 16 13:48:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     epsilon@socio.msu.ru
>Release:        6.8-23.fc9
>Organization:
>Environment:
Linux 2.6.27.7-53.fc9.i686 #1 SMP Thu Nov 27 02:29:03 EST 2008 i686 i686 i386 GNU/Linux

g++ (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8)
>Description:
When structure that have copy constructor is passed as a parameter, gdb prints it in a wrong way.

G++ (4.3.0) somehow pass this structure by reference, although it is formally passed by value. And GDB just reads all structure data from stack.

I compile program with "-g3 -ggdb" keys? Is that right?

For example if I compile the attached file and start it under gdb, 

(gdb) b foo
(gdb) run

Breakpoint 1, foo (a={a = -1075832884, b = 2}) at g2.cpp:8
8       int foo(bar a) { return 0; }


NOTE:
If I remove copy constructor, all is OK:

Breakpoint 1, foo (a={a = 2, b = 3}) at g2.cpp:8
8       int foo(bar a) { return 0; }

I understand that difference is in how G++ generates a code (different ways), but I still think, that is a gdb issue, since prev. version of gdb (i don't remember) was all right at managing it.
>How-To-Repeat:
[x@y tmp]$ g++ -g3 -ggdb g2.cpp
[x@y tmp]$ gdb a.out
...
(gdb) b foo
(gdb) run
Breakpoint 1, foo (a={a = -1075832884, b = 2}) at g2.cpp:8
8       int foo(bar a) { return 0; }

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-c++src; name="g2.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="g2.cpp"

c3RydWN0IGJhciB7CiAgaW50IGEsIGI7CgogIGJhcihpbnQgX2EsIGludCBfYikgOiBhKF9hKSwg
YihfYikge307CiAgYmFyKGNvbnN0IGJhciAmeCkgOiBhKHguYSksIGIoeC5iKSB7fTsKfTsKCmlu
dCBmb28oYmFyIGEpIHsgcmV0dXJuIDA7IH0KaW50IG1haW4oKSB7IHJldHVybiBmb28oYmFyKDIs
IDMpKTt9Cg==


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-12-16 13:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-16 13:48 c++/2567: Wrong representation of C++ structure with copy constructors passed as parameter epsilon

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).