From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E0E2B3854555; Tue, 29 Nov 2022 13:46:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E0E2B3854555 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669729578; bh=TH68EckJ48qGe0NIE4Px+vBGYEjJI7C/3jf9QJ0LXLg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=DAV+o2u9Hw89za7A1YPnHk5XXgEiVHfpqg8w0dHvfTUhm6srGYFXDp8MkIJ8J9U/M RAG3Tik4wWZuDx6bIucxtlQtq1v0E3PsafRBnvRQkkqREfds+xSaUwjFogw238+qvo Xc4WBeY6NO24777Zi8IaCxCf0eWC/5Fhbz3Q3ZvY= 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: Tue, 29 Nov 2022 13:46:18 +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 #6 from Carlos Galvez --- A similar case in the real world would be this: NumberSmallerThan3 getCount(); std::sort(data.begin(), data.begin() + static_cast(getCount())= ); The "NumberSmallerThan3" class holds and checks the invariant that "a numbe= r is smaller than 3". The compiler is not aware of that. Other real-world situation is Eigen-like code, where for performance reasons these checks can only be applied in debug mode, not release mode. We get warnings in release mode due to this.=