From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id /htlAqtMNGal0QMAWB0awg (envelope-from ) for ; Thu, 02 May 2024 22:32:11 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=fH7oIciB; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E6D821E0C1; Thu, 2 May 2024 22:32:10 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 CA19F1E030 for ; Thu, 2 May 2024 22:32:08 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 22023384770C for ; Fri, 3 May 2024 02:32:08 +0000 (GMT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 00036385E836 for ; Fri, 3 May 2024 02:31:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 00036385E836 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 00036385E836 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714703511; cv=none; b=kmFPfHrB/Qe5RhY8F7YvzBgAjqc/uTuJ4RvEjKHNgcyceP10fete24dQeeFkFp4ZV+X/76Rx/JWT6NniLWF6IbYAU/13cqSf+LKsRBHscLxzLyuSaVACL/jScNLQE8R7YN1xGpEXy2jOq94RP3AMAQaz2Aw0H+qSaqGXfmQlJew= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714703511; c=relaxed/simple; bh=jpzqh3FAXptqReQd6RivaV6jwCfbPVKy6YY6U7Fp3lc=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=uiEWJHehcjbfUGHBZrZ/Z7RuLYP6WCnD42Ak5l/z7ssyM0myNErSS5BFhg4uIkvlE7C6ndnlW2V8WyqeNYSI5L/B407x8M61GAw0bOVk4ylqkKFsNawi47ydwwqaZTNGGx4o59nUtPgnYjEupxjn+89IBBcIOgOkFDu+dk/NQco= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714703509; h=from:from:reply-to:subject:subject: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=pE5prMuO8Ihsy/cz8jZjXWftN/2j+p/j9Ar58h7OrHs=; b=fH7oIciBFDN3me1rjvrDNSpSL/ZI6cRNG8QNIWaeUJl/h2wBgPlwT4tRvBKhaP2PANZgqG WtOxn1YcEZowR+UP3lEtBqJe5nq0WSeHfdICfLVLEWZVZROsw8/4DAFQo647ieDV4W6KFw gURRrkIFllFcQ3tp0iSHH7EAm4UnFvQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-395-lWlcxIRXO8mucErpw99hiw-1; Thu, 02 May 2024 22:31:47 -0400 X-MC-Unique: lWlcxIRXO8mucErpw99hiw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 31AA480017B; Fri, 3 May 2024 02:31:47 +0000 (UTC) Received: from f39-zbm-amd (unknown [10.22.16.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E1CA62166B34; Fri, 3 May 2024 02:31:46 +0000 (UTC) Date: Thu, 2 May 2024 19:31:45 -0700 From: Kevin Buettner To: Tom de Vries Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] [gdb/exp] Fix cast handling for indirection Message-ID: <20240502193145.5da7327d@f39-zbm-amd> In-Reply-To: <20240502154902.22575-1-tdevries@suse.de> References: <20240502154902.22575-1-tdevries@suse.de> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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 Thu, 2 May 2024 17:49:02 +0200 Tom de Vries wrote: > Consider a test-case compiled without debug info, containing: > ... > char a = 'a'; > > char * > a_loc (void) > { > return &a; > } > ... > > We get: > ... > (gdb) p (char)*a_loc () > Cannot access memory at address 0x10 > ... > > There's a bug in unop_ind_base_operation::evaluate that evaluates > "(char)*a_loc ()" the same as: > ... > (gdb) p (char)*(char)a_loc () This surprised me. I would have thought that the evaluation would have been: (char)*(int)a_loc () ...due to the fact that functions lacking an explicit return type return 'int' in traditional C. > Cannot access memory at address 0x10 > ... > > Fix this by instead evaluating it the same as: > ... > (gdb) p (char)*(char *)a_loc () > $1 = 97 'a' > ... > > Tested on x86_64-linux. > > PR exp/31693 > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31693 Aside from the (possible) nit in the commit log that I mention above, the patch and test case look good to me. Approved-by: Kevin Buettner Kevin