From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 017133861936; Sun, 11 Jul 2021 18:23:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 017133861936 From: "simon.willcocks at gmx dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/101422] New: register variable uninitialised before passing to asm Date: Sun, 11 Jul 2021 18:23:50 +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: 10.3.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: simon.willcocks at gmx dot de 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 attachments.created 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Jul 2021 18:23:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101422 Bug ID: 101422 Summary: register variable uninitialised before passing to asm Product: gcc Version: 10.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: simon.willcocks at gmx dot de Target Milestone: --- Created attachment 51132 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D51132&action=3Dedit Source code fragment The attached program fragment sets up multiple register variables associated with specific ARM registers and runs some assembly code that makes use of t= hem. With -Os (and a generated memset to initialise a local array), some registe= rs are not correctly initialised, notably r0, which is corrupted by the addres= s of the array, and r3 which is not initialised at all before the asm instructio= n. r4, however, is correctly initialised. Affects arm-linux-gnueabi-gcc-10, arm-linux-gnueabi-gcc-9, and arm-linux-gnueabi-gcc-8. for opt in 1 2 3 4 s ; do for vers in 8 9 10 ; do arm-linux-gnueabi-gcc-$ve= rs problem.c -S -O$opt -Wall -Wextra -o problem-$vers-$opt.s ; done ; done To see the problem (the most obvious feature, at least): for i in problem*.s ; do echo ; echo $i ; grep r3 $i ; done In all three versions with -Os, the first mention of r3 is the asm code.=