From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 BC8613846062 for ; Fri, 3 May 2024 17:30:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BC8613846062 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 BC8613846062 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=1714757457; cv=none; b=DA8r2KVPMnLLBobkYwcf14/AzRBvxMb5nIIBlX3Ya4el273nnKIWl350ts7BGMBlnUAlaVQ6vuYK1jyqMm+A6uxgtQaaC4oJaraJfgKO+KnPuPIPcOyJ4BP1caGfVdf+HwZorh1H5UYEobS4pwwqAfHffqTZ9E251I82+gXZDkI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714757457; c=relaxed/simple; bh=IQW937ByZL9/vWwtSJQ4JLSKJPPacbkXZfEdMmDGnE8=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=Gn45hDeMI2M5uEi02bdE6U0cpD0w8xIL6rBYYS1rkcZcZBapYn5i23B2yCs1OJDR7zsjBOxHxscwAy4EJr1InfAXjPO/fnaBxLuWpCZKYkCJclJi+etMEqg6oDmN7rhEWlSSoWvATm4TbObNCWDjD1aQLBtDieOp9f/OVnSrPxE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714757456; 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=j+diObXU7Bgu5ocGMFSzXd0YK6Oh9CNzHcBKvb8je8o=; b=Sfl/Gi6q8cZn7Gc37c2EMi3swBSLqY7329qycSF3/i6gkcn48yduOTRiNuKInLE1VF5ZZ9 TLEoJm8+zwg7+I+MJR7tMmFR7bukWkU9ceIEiJK+kZSGnaTNCD5HyRZYxeq1TEMkq3Oh9z EOyp+NdCjC4isQ70ijgilOJE0Bpx3Ag= 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-113-tzvlIcu-OAKMf6uWY0hF5A-1; Fri, 03 May 2024 13:30:53 -0400 X-MC-Unique: tzvlIcu-OAKMf6uWY0hF5A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 9F8EB8A9141; Fri, 3 May 2024 17:30:52 +0000 (UTC) Received: from f39-zbm-amd (unknown [10.22.16.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2FD56AC68; Fri, 3 May 2024 17:30:52 +0000 (UTC) Date: Fri, 3 May 2024 10:30:50 -0700 From: Kevin Buettner To: Pedro Alves Cc: gdb-patches@sourceware.org, Tom Tromey , Tom de Vries Subject: Re: [PATCH] [gdb/exp] Fix cast handling for indirection Message-ID: <20240503103050.2ef46699@f39-zbm-amd> In-Reply-To: <51de396e-67fc-4451-a13e-091178d188f7@palves.net> References: <20240502154902.22575-1-tdevries@suse.de> <20240502193145.5da7327d@f39-zbm-amd> <8734qyex0l.fsf@tromey.com> <51de396e-67fc-4451-a13e-091178d188f7@palves.net> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,LOTS_OF_MONEY,MONEY_NOHTML,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, 3 May 2024 17:04:41 +0100 Pedro Alves wrote: > > I was wondering if this patch causes gdb to accept some weird things > > that might have been rejected in the past, by introducing a hidden cast. > > Maybe print (char) *85732 does something surprising now. I'm not > > entirely sure if that's bad. > > I am totally surprised that: > > +# Regression test for PR31693. > +gdb_test "p (char)*a_loc ()" " = 97 'a'" > > this actually works, instead of telling the user: > > "'a_loc' has unknown return type; cast the call to its declared return type" > > It seems like a misfeature to me to assume that "char *" is the right type. > > Thus, I don't agree with the patch. Using a GDB built with Tom de Vries's patch, I see: (gdb) p *a_loc() 'a_loc' has unknown return type; cast the call to its declared return type This is the same as the pre-patch behavior. With Tom's patch, GDB now infers the function's return type, based on the cast: (gdb) p (char)*a_loc() $1 = 97 'a' I like this behavior and certainly find it preferable to the behavior without his patch: (gdb) p (char)*a_loc() Cannot access memory at address 0x4 With regard to doing something like 'print (char) *85732', I don't see anything surprising... (gdb) p/d (char *)a_loc() $1 = 4210692 (I'll use 4210692 in place of 85732.) Pre-patch: (gdb) p *4210692 $2 = 97 (gdb) p (char)*4210692 $3 = 97 'a' With Tom de Vries's patch: (gdb) p *4210692 $9 = 97 (gdb) p (char)*4210692 $10 = 97 'a' Kevin