From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 33F163857C48; Wed, 2 Sep 2020 18:57:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 33F163857C48 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1599073039; bh=mnjz+hFj0neS/Kh4tdcOCjRJA7WYuUr3t/yRYnAt6oQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=YsOqMkXEhLRHDnW9BZcGR4RSOrCNDQVNLCvkrC9YPORYa9p40/j5OPyRsmFiHT/cf eEaJCZeQ8KyxEeqLMa0OocupmEXF1pDUD5704zcWitQS+hNCv5q/xSQlaEPFcAvWrA 4K1buV0ir5ChJ40y/MPYu63O2RKGfvhUwSApz0MM= From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/96900] [9/10/11 Regression] bogus -Warray-bounds on strlen with valid pointer obtained from just-past-the-end Date: Wed, 02 Sep 2020 18:57:19 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org 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: 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 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: Wed, 02 Sep 2020 18:57:19 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96900 --- Comment #2 from Martin Sebor --- The underlying cause is fold_nonarray_ctor_reference() returning a scalar z= ero for apparently out-of-bounds references when determining the initializer for s.a from &s.a[sizeof s.a]. Its caller, constant_byte_string(), then interp= rets that as an array of single element initialized to zero, but it incorrectly returns the offset from the beginning of s (i.e., 4 rather than 3 minus 3 f= or sizeof s.a). Its caller, c_strlen(), then uses the size of the one-element initializer (for "") and the offset (positive 1) as the basis for issuing t= he warning.=