From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id q0IHAZCi9GmVAAkAWB0awg (envelope-from ) for ; Fri, 01 May 2026 08:54:40 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=kznFFn04; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Cy/JZbSQ; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=kznFFn04; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Cy/JZbSQ; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E57C61E067; Fri, 01 May 2026 08:54:39 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 1DB851E067 for ; Fri, 01 May 2026 08:54:39 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id C8A9346A9CC0 for ; Fri, 1 May 2026 12:54:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C8A9346A9CC0 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=kznFFn04; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Cy/JZbSQ; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=kznFFn04; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Cy/JZbSQ Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 881984A9A88F for ; Fri, 1 May 2026 12:54:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 881984A9A88F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 881984A9A88F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777640052; cv=none; b=kKIDR3dzPRhq9rYxnIhXu9VEu2wU6oD8DWF/4Sb7JrsLsnqjCoc/4MtQrMyJgcQcDvxiLNt4ltIo1EW1nw/miJEzYifI/J6vEe4MAvfcqHGhmCHB5cEnz/AW6GN75zJZlMikPtR+K7BU3zOblBUWPY6RFUYA4uevxZmMMMcPV+8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777640052; c=relaxed/simple; bh=K8PJzHqjoQBeoJoX9Ft6xY7AjnxMWC9sPPLdNHaf3RE=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:From:To; b=cRTesmlEAHzjZbj68CjkWWhtMyjAvz2aK4fVMG6esqQ+Aid+0b1nNTZLbP+61WDhTZI/k/hF99S65uHxHVR0WcOgLqMOjlTcM2AveySaxmO2Pk8OzwUPcEh20BH1RuLzxcK1wQAmgZXdpW81lkSkJtuOKQpm9rZbjRFKv2/t6XE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 881984A9A88F Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4DCFF5BD25; Fri, 1 May 2026 12:54:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1777640051; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V9OflozoBJwOno0oho5mLgsycKaGW+erF/A1XwaOg+Q=; b=kznFFn043p5xCEbQ+toTUa18ivS07ijFXj2oEIKzZLRuc/c/ruUZoBguGo1GhepM5wiszR ljmEdtUzt8plSA2kUzNzvvEFRxciOr5kLxyX+DlWaoCHncvB3nvffMplLOFqd3YAgeCiSt ijx5VOcqgK/SRXkd3SvEgRI3acb+G0U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1777640051; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V9OflozoBJwOno0oho5mLgsycKaGW+erF/A1XwaOg+Q=; b=Cy/JZbSQ2QeJd93fakLOu8/tFCdViwIcLvL0FSitMSaDWx4xPc9GsdJZR8oCvvddFI/2IC ddeACyaB9j9PiZBA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=kznFFn04; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="Cy/JZbSQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1777640051; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V9OflozoBJwOno0oho5mLgsycKaGW+erF/A1XwaOg+Q=; b=kznFFn043p5xCEbQ+toTUa18ivS07ijFXj2oEIKzZLRuc/c/ruUZoBguGo1GhepM5wiszR ljmEdtUzt8plSA2kUzNzvvEFRxciOr5kLxyX+DlWaoCHncvB3nvffMplLOFqd3YAgeCiSt ijx5VOcqgK/SRXkd3SvEgRI3acb+G0U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1777640051; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V9OflozoBJwOno0oho5mLgsycKaGW+erF/A1XwaOg+Q=; b=Cy/JZbSQ2QeJd93fakLOu8/tFCdViwIcLvL0FSitMSaDWx4xPc9GsdJZR8oCvvddFI/2IC ddeACyaB9j9PiZBA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 349E6593B0; Fri, 1 May 2026 12:54:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id T7CBCnOi9GkxcAAAD6G6ig (envelope-from ); Fri, 01 May 2026 12:54:11 +0000 Message-ID: <6201f741-6cd9-4d37-ab6b-9c888f4069d2@suse.de> Date: Fri, 1 May 2026 14:54:10 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/7] [gdbsupport] Factor out base_next_iterator From: Tom de Vries To: Tom Tromey Cc: gdb-patches@sourceware.org References: <20260423063530.1074175-1-tdevries@suse.de> <20260423063530.1074175-4-tdevries@suse.de> <87340kpbwx.fsf@tromey.com> <91f3f93c-e4c9-410d-a5b6-93d0cdfd2414@suse.de> Content-Language: en-US In-Reply-To: <91f3f93c-e4c9-410d-a5b6-93d0cdfd2414@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_TLS_ALL(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; MID_RHS_MATCH_FROM(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[sourceware.org:url,suse.de:dkim,suse.de:mid,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 4DCFF5BD25 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 4/30/26 6:49 AM, Tom de Vries wrote: > On 4/24/26 6:21 PM, Tom Tromey wrote: >> Tom> +   Instead of factoring out a base class, we could use something >> like this: >> Tom> + >> Tom> +     template >> Tom> +     struct next_iterator >> Tom> +     { >> Tom> +       ... >> Tom> +       self_type &operator++ () >> Tom> +       { >> Tom> +     m_item = m_item->*F; >> Tom> +     return *this; >> Tom> +       } >> Tom> +       ... >> Tom> +     } >> Tom> + >> Tom> +  but that has the drawback that it doesn't work with incomplete >> T.  */ >> I am curious about this because I wonder how the current code could work >> with an incomplete T -- since the code references T::next directly. > > Yeah, that's a good question. > > I wrote the following stand-alone demonstrator: > ... > $ cat test.c > #include > #include > #include > #include > > #include "gdbsupport/next-iterator.h" > > struct list; > > void > print_pointer (list *l) > { >   auto begin = next_iterator (l); >   for (auto elem : next_range (begin)) >     printf ("%p\n", elem); > } > > struct list > { >   int i; >   struct list *next; > }; > > void > print_int (list *l) > { >   auto begin = next_iterator (l); >   for (auto elem : next_range (begin)) >     printf ("%d\n", elem->i); > } > > struct list a = { 1, nullptr }; > struct list b = { 2, &a }; > struct list c = { 3, &b }; > > int > main () > { >   print_pointer (&c); >   print_int (&c); > >   return 0; > } > $ g++ test.c -I . > $ ./a.out > 0x404040 > 0x404030 > 0x404020 > 3 > 2 > 1 > $ > ... > > I asked an LLM about this, and it explained that this is deferred or > delayed template instantiation at work. > > Basically the operator++ is used in print_pointer, but not yet > instantiated, so we don't have to know the details of the incomplete > type at that point. I've written a next_iterator unit test, and added (part of) this demonstrator ( https://sourceware.org/pipermail/gdb-patches/2026-May/227065.html ). Thanks, - Tom