From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3DFB9385DC32; Thu, 23 Apr 2020 05:14:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3DFB9385DC32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587618879; bh=6/Ob+0Z1qCBwFzBfH4LRIX8ME+kvYc8i4qwfNms14Kk=; h=From:To:Subject:Date:From; b=jgcwVxCjmS0NMm91GveqHUFmlhSM5wEUnr8W2GH3TL5wOYJc+LDvnxkWdRfsYTDXS FK0bkcAB/Bk2pnIagVMhVmaYw2+3LRX5QrD78qwd1BoebUe/FnJll5+xJdujzweByH 68lTEV32/hG4Wq8C0voP/+0Y/yBOuIb35NHdiJfc= From: "vsevolod.livinskij at frtk dot ru" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/94727] New: GCC produces incorrect code with -O3 Date: Thu, 23 Apr 2020 05:14:39 +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: 10.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, 23 Apr 2020 05:14:39 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94727 Bug ID: 94727 Summary: GCC produces incorrect code with -O3 Product: gcc Version: 10.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: --- GCC produces incorrect code with -O3. Reproducer: >$ cat func.cpp=20 extern bool var_3; extern unsigned long long int var_11; extern unsigned char arr_41 [14] [14] [19] [16] [18] ; extern long long int arr_42 [14] [14] [19] [16] [18] ; void test() { for (int a =3D 0; a < 3; a++) for (char b =3D 0; b < 3; b =3D 4) for (int c =3D 0; c < 8; c++) for (short d =3D 0; d < 5; d +=3D 4) for (char e =3D 0; e < 17; e++) arr_42[a][b][c][d][e] =3D (arr_41[a][b][c][d][e] < var_11) > va= r_3; } >$ cat driver.cpp=20 #include bool var_3 =3D (bool)0; unsigned long long int var_11 =3D 14035841137156193017ULL; unsigned char arr_41 [14] [14] [19] [16] [18] ; long long int arr_42 [14] [14] [19] [16] [18] ; void test(); int main() { for (size_t i_0 =3D 0; i_0 < 14; ++i_0) for (size_t i_1 =3D 0; i_1 < 14; ++i_1) for (size_t i_2 =3D 0; i_2 < 19; ++i_2) for (size_t i_3 =3D 0; i_3 < 16; ++i_3) for (size_t i_4 =3D 0; i_4 < 18; ++i_4) arr_41 [i_0] [i_1] [i_2] [i_3] [i_4] =3D (unsigned char)226; for (size_t i_0 =3D 0; i_0 < 14; ++i_0)=20=20 for (size_t i_1 =3D 0; i_1 < 14; ++i_1) for (size_t i_2 =3D 0; i_2 < 19; ++i_2) for (size_t i_3 =3D 0; i_3 < 16; ++i_3) for (size_t i_4 =3D 0; i_4 < 18; ++i_4) arr_42 [i_0] [i_1] [i_2] [i_3] [i_4] =3D -5577957210778461327LL; test(); printf("%lld\n", arr_42[0][0][0][0][0]); } Error: >$ g++ func.cpp driver.cpp -O0 && ./a.out=20 1 >$ g++ func.cpp driver.cpp -O3 && ./a.out=20 0 GCC version: 10.0.1 (87841658d4fa5174d1797ee0abc73b3b3f11cad4)=