From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 85D373858402; Fri, 5 Apr 2024 06:03:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 85D373858402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712297037; bh=pdRAvN3oh25GqVek+27sU1daVlEd7W85eVHda1uPO/M=; h=From:To:Subject:Date:In-Reply-To:References:From; b=t8kAchuz0t366Yn+BVdL046aDj6tlR9BIkM5cSAQmEa3jjPkfKQtQC9U+SxV8cmds +I5y7RNFmM+RVhtAYQAvrgUb0culGBHcMpJxJGtBv8adWvn6IYngNQNh+iDccR7aBH gQw35Nh2CL6K2XEhOYdN+31VCvF4/1H83ULRq/fQ= From: "xry111 at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/114597] [GCC-14] Miscompilation of pointer assignment with inline assembly Date: Fri, 05 Apr 2024 06:03:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: xry111 at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114597 Xi Ruoyao changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |xry111 at gcc dot gnu.org --- Comment #4 from Xi Ruoyao --- (In reply to wierton from comment #3) > Thanks a lot, I have checked it out. >=20 > I'm still somewhat confused. Does the difference in compilation stem from > GCC interpreting "=3Dm" and "=3Dr" differently, leading it to assume that= once > "n.p" is declared as an output operand without matched input declaration > (eg. "=3Dm" expects "m", "=3Dr" expects "r"), its value is expected to ch= ange? >=20 > ``` > asm("":"=3Dm"(n.p):"r"(n.p)); // n.p is expected to change > asm("":"=3Dr"(n.p):"r"(n.p)); // n.p can retain its value > asm("":"=3Dm"(n.p):"m"(n.p)); // n.p can retain its value > ``` I believe the second form is still incorrect and it just works by luck. To ensure it work you have to do: asm("mov %1,%0":"=3Dr"(n.p):"r"(n.p)); Or asm("":"+r"(n.p)); Not so sure about the third form.=