From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 45D92386F828; Thu, 28 May 2020 20:44:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 45D92386F828 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1590698667; bh=QiHHGsV6vd2S+kkUJsfETEbBx2069xj1+9x4Fqt2Oz8=; h=From:To:Subject:Date:From; b=j5EYaKX3gCFPEWo9/mKm/Qk3m4qQNUCgRZ27igrnjiRQidtM5wsXq5qBMCwKmQwmd SJNCqhlQaUVLmrpJXDoueVnVG1qAEsKPLDrDAAU2xJ0ty1wtk3h2pO9rBsqvv4cK1q 9xvhqT8XB3H1I9mzQyGKn6DA8zEIorSV6ct6l0AE= From: "vsevolod.livinskij at frtk dot ru" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/95396] New: GCC produces incorrect code with -O3 for loops Date: Thu, 28 May 2020 20:44:27 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vsevolod.livinskij at frtk dot ru 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 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: Thu, 28 May 2020 20:44:27 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95396 Bug ID: 95396 Summary: GCC produces incorrect code with -O3 for loops Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vsevolod.livinskij at frtk dot ru Target Milestone: --- Error: >$ g++ -O0 small.cpp && ./a.out=20 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 0 0 0=20 >$ g++ -O3 small.cpp && ./a.out=20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 42 0 0 0=20 Reproducer: >$ cat small.cpp=20 #include unsigned short arr_26 [20]; signed char arr_25 [2000]; unsigned char b; int c(int d, int f) { return d > f ? d : f; } void test() {=20 for (char e =3D c(b, 241) + 15; e < 17; e +=3D 1) arr_26[e] =3D 42; } int main() { test(); for (size_t i_0 =3D 0; i_0 < 20; ++i_0) printf("%d ", arr_26 [i_0]); printf("\n"); } GCC version: 11.0.0 (1852a26b925970f64f8d31518ba732fe9c3ade23)=