This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/2567: Wrong representation of C++ structure with copy constructors passed as parameter


>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==


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]