C++ nested class bug/questions

Willgerodt, Felix felix.willgerodt@intel.com
Tue Jun 22 11:27:37 GMT 2021


Hello everyone,

I was debugging a program similar to the one attached and noticed a couple
of unexpected things happening. I compiled it with ”-g -O0” and g++ 11.1.0
(clang showed similar behaviour) and saw this:

(gdb) bt
#0  DF::vvv (this=0x7fffffffd120) at foo.cc:11
#1  0x0000555555555180 in foo () at foo.cc:16
#2  0x00005555555551a7 in main () at foo.cc:20
(gdb) ptype abcd
type = class DF::FFFF {
  private:
    int ffff;
}
(gdb) ptype FFFF
No symbol "FFFF" in current context.
(gdb) ptype DF::
FFFF   vvv()  
(gdb) ptype DF::FFFF
There is no field named FFFF
(gdb) ptype 'DF::FFFF'
type = class DF::FFFF {
  private:
    int ffff;
}
(gdb)

(The fourth command shows tab completion.)

The problems I see are:
1) I think it shouldn’t be DF::FFFF.
2) 'ptype FFFF’ should just work as it is in the current scope.
3) There shouldn’t be a need to quote DF:FFFF, right? Although that might just be a side-effect here.
4) The fact that a suggestion from tab completion doesn’t work is annoying. This is probably also be a side-effect.

Before debugging this further, I wanted to see if there are any comments/suggestions.
Am I even right about point 1? I couldn’t really find anything definitive
in my favourite cpp reference on this type of nesting. g++ and clang output FFFF as
foo()::DF::vvv()::FFFF as far as I can see.

I don’t see any obvious problems in the dwarf that is produced.

Thanks,
Felix

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.cc
Type: application/octet-stream
Size: 227 bytes
Desc: foo.cc
URL: <https://sourceware.org/pipermail/gdb/attachments/20210622/debf8782/attachment.obj>


More information about the Gdb mailing list