From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 601BA3858C2D; Thu, 9 Feb 2023 12:35:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 601BA3858C2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675946149; bh=W5znUoneNS92CkLwPFDeQtB2pH8MpmSDWE3k82/Hiek=; h=From:To:Subject:Date:From; b=tEOh+6wEW6LI0t8BZI9qpQFGEFwhdDeMJvfucoJlBntvNQ+juWpNKQTcerr5ry+Ze OFYwR0bSjmRP5B26WUuIBij/wq5xf4ViT/yFd/qKu3Wc1qxEQWmXUzGttqwpJxfp/I 9HIy7Z9r7NOWDjFh7fri7I6N94aTv7ufIgV7WA8Q= From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/108741] New: [OpenMP] Wrong code for lastprivate with pointer iteration variable Date: Thu, 09 Feb 2023 12:35:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108741 Bug ID: 108741 Summary: [OpenMP] Wrong code for lastprivate with pointer iteration variable Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: jakub at gcc dot gnu.org Target Milestone: --- The motivation is Fortran code, based on libgomp/testsuite/libgomp.fortran/non-rectangular-loop-3.f90 for PR107424 and with the patch applied from https://gcc.gnu.org/pipermail/gcc-patches/2023-January/610584.html However, the issue is preexisting and probably fails already since ever. It shows also up with a questionable C code, which tries to mimic the Fortr= an code. The problem is that '**a0' in the loop body points to invalid memory. //----- (questionable) C testcase ------ void foo(int **a1) { int j, a0; #pragma omp simd collapse(2) lastprivate(a0,a1,j) for (a0 =3D 1; a0 <=3D 10; a0++) for (j =3D 1; j <=3D 20; j++) **a1 =3D a0; /// Segfaults here as *a0 points to invalid memory if (**a1 !=3D 10 || j !=3D 21 || a0 !=3D 11) __builtin_abort (); } int main() { int *a1, a2; a2 =3D 5; a1 =3D &a2; foo (&a1); return 0; } ! Fortran testcase implicit none integer, pointer :: a1 allocate(a1) call o(a1) contains subroutine o(a1) implicit none integer :: j integer, pointer :: a1 !$omp simd collapse(2) lastprivate(a1,j) do a1 =3D 1, 10 do j =3D 1, 20 end do end do if (a1 /=3D 11 .or. j /=3D 21) error stop end end=