From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 771793858409; Thu, 16 Feb 2023 10:37:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 771793858409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676543872; bh=qzNCYwl/klayt5stNvNjyryUY8Hupx8xgyf4P0gKAUY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=alMuKs/Iab/BbBp/I6z+R1J100U86m1OAcHca+F1twfA1b3jvuZG2xEH2R3sEeR2G QViQ8FeHH+7nWxfCBKSmyT3TdH6yjEK4Im8p/nOniC3o5JbwOQK4mAhzFTjC1PfOuH 8xY5uFBlUOOVvI58K2qasJJGY2Y+Z93pz4FnpQmI= From: "carlosgalvezp at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107699] [12/13 Regression] False positive -Warray-bounds, non-existent offset reported by GCC Date: Thu, 16 Feb 2023 10:37:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: carlosgalvezp at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107699 --- Comment #11 from Carlos Galvez --- Consider this more realistic example: https://godbolt.org/z/jbbqbe8d9 The compiler has all the information available to ensure that getCount().ge= t() is smaller than 3, as enforced by the class invariant which is visible to t= he compiler. Class invariants help us not having to check things all the time.= For example gsl::not_null allows us to not have to check for nullptr on every u= se.=