From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 25F16385627D; Fri, 22 Apr 2022 10:38:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 25F16385627D From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/105345] New: [OpenMP] Wrong iteration loop count when mixing signed and unsigned Date: Fri, 22 Apr 2022 10:38:21 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: openmp, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus 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: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter cc 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: Fri, 22 Apr 2022 10:38:22 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105345 Bug ID: 105345 Summary: [OpenMP] Wrong iteration loop count when mixing signed and unsigned Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: openmp, wrong-code Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: frederik at gcc dot gnu.org, jakub at gcc dot gnu.org Target Milestone: --- The following program has a loop count of 0 without OpenMP (-fno-openmp) but is executed 1010 times with -fopenmp in GCC. The problem is that the following is not honored: "If var has a signed integer type and the var operand of test-expr after us= ual arithmetic conversions has an unsigned integer type then the loop iteration count is computed from lb, test-expr and incr using an unsigned integer type corresponding to the type of var." (OpenMP 5.2, 4.4.2 OpenMP Loop-Iteration Spaces and Vectors) (Likewise: OpenMP 5.1, 2.11.1 Canonical Loop Nest Form) The wording seems to be new since OpenMP 5.1 - and to ensure that the OpenMP and C loop counts are the same: int main () { #pragma omp for for (int i =3D -1000; i < 10u; ++i) { __builtin_printf("%d\n", i); __builtin_abort (); }=20 }=