From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9CA503858402; Fri, 5 Apr 2024 03:42:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9CA503858402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712288556; bh=zTBfxAgWQV42hCYuM0Gv2ZOAFY0ces1hrlyVpScoh5g=; h=From:To:Subject:Date:From; b=WoHFOZH39QpN94uzea1NGX9k16oh0nUbuoloaXXaRu90JGSx63qtbEJHXL4ig2r7I XM/EKmCJuWoX4wp8ArpeEXEBUJkYrcF/mcHepirwuj8NBctsGLQu16YG5Ax3ihXTGw ILPZjT47VT7siSEKsCbmopln3ZHxP0+Oc9FigPpk= From: "141242068 at smail dot nju.edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/114597] New: [GCC-14] Miscompilation of pointer assignment with inline assembly Date: Fri, 05 Apr 2024 03:42:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new 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: 141242068 at smail dot nju.edu.cn X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 Bug ID: 114597 Summary: [GCC-14] Miscompilation of pointer assignment with inline assembly Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: 141242068 at smail dot nju.edu.cn Target Milestone: --- Compiler Explorer: https://gcc.godbolt.org/z/Pn4EG3zzj ``` struct node { void *p; } n; struct head { struct node *n; } h; int main () { n.p =3D &h; asm("":"=3Dm"(n.p):"r"(n.p)); if (n.p !=3D &h) __builtin_abort(); return 0; } ``` I sanitized this program with all sanitizers I know, they report nothing. When compile this program with `gcc-14 -O2`, the compiled program aborts, w= hile `-O0` normally exits. Any potential undefined behavior: 1. strict aliasing, I added option `-fno-strict-aliasing` to `-O2`, the abo= rt still exists. 2. If there is some other undefined behavior unknown to me cause this compilation inconsistency, please let me know. Regarding the inline assembly, it's important to note that even though `n.p= ` is specified as an output operand with `=3Dm`, this doesn't necessarily imply = that `n.p` will be altered. The inline assembly might simply reassign the origin= al value to `n.p`, leaving it effectively unchanged.=