From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway21.websitewelcome.com (gateway21.websitewelcome.com [192.185.45.212]) by sourceware.org (Postfix) with ESMTPS id 6538439A543D for ; Wed, 28 Jul 2021 21:19:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6538439A543D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tromey.com Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 0D75B404F6ADB for ; Wed, 28 Jul 2021 15:54:38 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 8pWjmwexIoIHn8pWjm04XO; Wed, 28 Jul 2021 14:47:46 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=7HooqaXje9kSDEt8RUZ5iLSWgsb0lJqHg6QsiqrM+rg=; b=mjNbhiBo31EBtJv2TE7qVIAmPT pIgknXvJcoW8Yrnbb358XDo5389GYHgAABZbz3us0nErZvS3YIelkjg/seb5SydzODDQfBGcCv7P7 sVUIx3cpy1/WfrqJdMJZUyOx/; Received: from 97-122-74-117.hlrn.qwest.net ([97.122.74.117]:35896 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1m8pWi-002VV8-OG; Wed, 28 Jul 2021 13:47:36 -0600 From: Tom Tromey To: Simon Marchi via Gdb-patches Subject: Re: [PATCH 15/16] gdb: make cmd_list_element var an optional union References: <20210714045520.1623120-1-simon.marchi@polymtl.ca> <20210714045520.1623120-16-simon.marchi@polymtl.ca> X-Attribution: Tom Date: Wed, 28 Jul 2021 13:47:36 -0600 In-Reply-To: <20210714045520.1623120-16-simon.marchi@polymtl.ca> (Simon Marchi via Gdb-patches's message of "Wed, 14 Jul 2021 00:55:19 -0400") Message-ID: <87wnpacjaf.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.74.117 X-Source-L: No X-Exim-ID: 1m8pWi-002VV8-OG X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-74-117.hlrn.qwest.net (murgatroyd) [97.122.74.117]:35896 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3023.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, URIBL_CSS_A autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Jul 2021 21:19:44 -0000 >>>>> "Simon" == Simon Marchi via Gdb-patches writes: Simon> I propose changing cmd_list_element to be a union of all the possible Simon> pointer types. Fundamentally, this doesn't change much what is Simon> happening. But I think this helps understand better how the field is Simon> used and get a bit of type safety (while it is still possible to use the Simon> wrong member at some point, we can't cast to something completely Simon> unrealted). Makes sense to me. Simon> I wrapped the union in an optional, because we need to check in some Simon> spots whether var is set or not. I think that conceptually, an optional Simon> makes the most sense. Another option would be to pick an arbitrary Simon> member of the union and compare it to nullptr, whenever we want to know Simon> whether var is set, but that seems a bit more hack-ish. There could be a "void *null_if_not_set" member that's only used for the check. This would save some space. Not sure it matters though. Tom