From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 25E5F3858298; Mon, 21 Aug 2023 10:09:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 25E5F3858298 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692612549; bh=M+zsjQH9fNHDFfhiDT983ivWUXrwtqKoo0ZlTgNOL58=; h=From:To:Subject:Date:From; b=RO7vljoRtxGMgEk56IYqCI6kfjFRsSDjaN/qIINB1jZppmr2OhWwSfXHkMR3ULIJ+ jMBf+ryltgM8zS48HSibIRSaHDncH/RrigyMc0SW3Sph5gncnyVLTGn/aDI59oPhWC qAEhKoPiy6WrFT69WAm6/tQAlK+c2Bqatf8Wdpgw= From: "charly.poyac at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/111088] New: useless 'xor eax,eax' inserted when a value is not returned. Date: Mon, 21 Aug 2023 10:09:08 +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: 13.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: charly.poyac at gmail dot com 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=3D111088 Bug ID: 111088 Summary: useless 'xor eax,eax' inserted when a value is not returned. Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: charly.poyac at gmail dot com Target Milestone: --- I compile this simple C code with GCC 13.2: int foo(int *a) { *a +=3D 1; } int foo2(int *a) { *a +=3D 1; }=20 and it produces the following assembly code with '-O3': foo: add DWORD PTR [rdi], 1 ret foo2: add DWORD PTR [rdi], 1 xor eax, eax ret see godbolt: https://godbolt.org/z/eeT63ePcr We can see the inconsistency between the two functions with the 'xor eax,ea= x' added in foo2. This does not happen if I compile with -O1. Yes, these functions should return an integer, but they don't. However, thi= s is allowed by the C standard (2018 6.9.1 11/12).=