From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5A0F83858D39; Fri, 21 Oct 2022 05:57:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5A0F83858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666331822; bh=Sa+vsGzXGTugrOKjCRNh3Qe4EeIYVh4Xtv4N7aSpg5o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=IRw/sPWKQ+D0IeZLczjwG1+gN9vAIo5CC4r9/eRzstc1NhvjCno7Yb/omqS48F6UQ rq3578OhRCUex3xISKZT3QD2+MB97O06DItGHtyIB2h1fmtfzGFzfPH/EMm44usG/d 6kPjt70xXqVutBQxKyepFTi5TsU7BLVdAUCqHI2M= From: "lh_mouse at 126 dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/105523] Wrong warning array subscript [0] is outside array bounds Date: Fri, 21 Oct 2022 05:57:01 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: lh_mouse at 126 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: 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=3D105523 LIU Hao changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lh_mouse at 126 dot com --- Comment #6 from LIU Hao --- We have been experiencing this on mingw-w64 too. The warning can be caused = by ``` void* teb(void) { void* self; __asm__ ("movq %%gs:%1, %0" : "=3Dr"(self) : "m"(*(void**) 0x30)); return self; } ``` ``` :5:52: warning: array subscript 0 is outside array bounds of 'void *[0]' [-Warray-bounds] 5 | __asm__ ("movq %%gs:%1, %0" : "=3Dr"(self) : "m"(*(void**) 0x30= )); |=20=20=20 ``` GCC 11 emits no such warning. (godbolt: https://gcc.godbolt.org/z/sG7fG9x9j)=20 Apparently GCC thinks we are dereferencing `0x30` which is a dangling point= er however that is exactly what we want to do, so GCC shouldn't have warned in this case.=