From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 51A493858412; Wed, 20 Mar 2024 17:25:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 51A493858412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1710955525; bh=ODHYGi81OKMkQm7tJ60ZKcCL68IAOahlOG60dmLkFRA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=CIFFTmYNJ+1JIVPxJXIx8ljPmy28J4UBaPKmkq/rR2dKuDB5q8YZjn3VRxVoKxU8U ZwXT0Ljz7X/Js38oXC+J5w7ijV22OPuf0YBIODfXILhCBtgddIwCUEhsgfH3m4RE+a imZXtYEcsUBKHxBjSdJO41qN44WRx7GezytZicfI= From: "cvs-commit at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug gdb/19423] __int128 conversion towards "const __int128 &" should be allowed Date: Wed, 20 Mar 2024 17:25:24 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: 7.10 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D19423 --- Comment #1 from Sourceware Commits --- The master branch has been updated by Hannes Domani : https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dd391f3721e20= d160909a3afae7fee647ea5575a2 commit d391f3721e20d160909a3afae7fee647ea5575a2 Author: Hannes Domani Date: Wed Mar 20 18:23:40 2024 +0100 Fix casting in-memory values of primitive types to const reference It's currently not possible to cast an in-memory value of a primitive type to const reference: ``` (gdb) p Q.id $1 =3D 42 (gdb) p (int&)Q.id $2 =3D (int &) @0x22fd0c: 42 (gdb) p (const int&)Q.id Attempt to take address of value not located in memory. ``` And if in a function call an argument needs the same kind of casting, it also doesn't work: ``` (gdb) l f3 39 int f3(const int &i) 40 { 41 return i; 42 } (gdb) p f3(Q.id) Attempt to take address of value not located in memory. ``` It's because when the constness of the type changes in a call to value_cast, a new not_lval value is allocated, which doesn't exist in the target memory. Fixed by ignoring const/volatile/restrict qualifications in value_cast when comparing cast type to original type, so the new value will point to the same location as the original value: ``` (gdb) p (int&)i $2 =3D (int &) @0x39f72c: 1 (gdb) p (const int&)i $3 =3D (const int &) @0x39f72c: 1 (gdb) p f3(Q.id) $4 =3D 42 ``` Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D19423 Approved-By: Tom Tromey --=20 You are receiving this mail because: You are on the CC list for the bug.=