This is the mail archive of the gdb-patches@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]

Re: [PATCH] Fix PR c++/23373: GDB hangs when printing a struct with a static member of itself


On 2018-07-07 05:26 PM, Sergio Durigan Junior wrote:
> 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?

Thanks, LGTM.  It would make sense to have it in 8.2 I believe.

Simon


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