This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug c++/23373] ptype/o is hanged on static struct member of the same type as struct is
- From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Wed, 11 Jul 2018 18:56:05 +0000
- Subject: [Bug c++/23373] ptype/o is hanged on static struct member of the same type as struct is
- Auto-submitted: auto-generated
- References: <bug-23373-4717@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=23373
--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The gdb-8.2-branch branch has been updated by Sergio Durigan Junior
<sergiodj@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ad3c631a762734c39b85086d20ba28940c2fc9b8
commit ad3c631a762734c39b85086d20ba28940c2fc9b8
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Sat Jul 7 17:16:55 2018 -0400
Fix PR c++/23373: GDB hangs when printing a struct with a static member of
itself
This patch fixes a failure that happens when a structure has a static
member whose type is the same as itself. From the bug report:
Example code:
struct A
{
static A Empty;
int a;
};
int main(void) {
A a;
return 0;
}
Output:
(gdb) ptype/o A
/* offset | size */ type = struct A {
static struct A {
static struct A {
static struct A {
static struct A {
static struct A {
static struct A {
... # infinite loop
The problem here is that GDB is not taking into account the fact that
static members inside a class/struct are not stored in the
class/struct, and therefore they should not be accounted for during
the display of the offsets/sizes. The fix is simple: we just check if
the field we're dealing with (on
c-typeprint.c:c_type_print_base_struct_union) is static, and if it is
then we don't iterate over it.
This patch also adds a new test for this case, and doesn't introduce
any regressions. I believe it is important enough to be included in
the 8.2 branch.
OK?
gdb/ChangeLog:
2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com>
PR c++/23373
* c-typeprint.c (c_type_print_base_struct_union): Don't print
offsets/sizes for static members of a class/struct.
gdb/testsuite/ChangeLog:
2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com>
PR c++/23373
* gdb.base/ptype-offsets.cc (struct static_member): New
struct.
(main) <stmember>: New variable.
* gdb.base/ptype-offsets.exp: Add test for printing a struct
with a static member in it.
--
You are receiving this mail because:
You are on the CC list for the bug.