From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id B67D03939C23 for ; Tue, 22 Jun 2021 19:01:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B67D03939C23 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 15MJ14BO022367 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Jun 2021 15:01:09 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 15MJ14BO022367 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id C1A9B1EE14; Tue, 22 Jun 2021 15:01:04 -0400 (EDT) Subject: Re: C++ nested class bug/questions To: "Willgerodt, Felix" , "gdb@sourceware.org" References: <391f40b3730d4f2486b3fcd324cf4c31@intel.com> From: Simon Marchi Message-ID: <5d280321-c8b7-46b7-8dad-c55601afdc30@polymtl.ca> Date: Tue, 22 Jun 2021 15:01:04 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <391f40b3730d4f2486b3fcd324cf4c31@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 22 Jun 2021 19:01:04 +0000 X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jun 2021 19:01:16 -0000 On 2021-06-22 7:27 a.m., Willgerodt, Felix via Gdb wrote: > 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 I'm not a reference on this topic, but at first glance I agree with you. Simon