public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "reubendb at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/97592] New: Incorrectly set pointer remapping with array pointer argument to CONTIGUOUS dummy Date: Tue, 27 Oct 2020 14:25:28 +0000 [thread overview] Message-ID: <bug-97592-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97592 Bug ID: 97592 Summary: Incorrectly set pointer remapping with array pointer argument to CONTIGUOUS dummy Product: gcc Version: og10 (devel/omp/gcc-10) Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: reubendb at gmail dot com Target Milestone: --- Hi, The following code produces an incorrect results with GCC 10.1.0, 10.2.0. The code works as expected with GCC/6.4.0,7.4.0,8.1.0,8.1.1 program RemappingTest implicit none real, dimension ( :, : ), pointer :: & B_2D real, dimension ( :, :, : ), pointer :: & B_3D !-- Prepare B_2D allocate ( B_2D ( 16, 3 ) ) B_2D = - huge ( 1.0 ) !-- Point B_3D to Storage call SetPointer ( B_2D, 4, 4, 3, B_3D ) !-- Set B_3D B_3D = 2.0 !-- See if the result is reflected in Storage print* print*, "B_2D = ", B_2D !-- expect 2.0 for all elements contains subroutine SetPointer ( C_2D, n1, n2, n3, C_3D ) real, dimension ( :, : ), intent ( inout ), target, contiguous :: & C_2D integer :: & n1, n2, n3 real, dimension ( :, :, : ), intent ( inout ), pointer :: & C_3D C_3D ( 1 : n1, 1 : n2, 1 : n3 ) => C_2D end subroutine SetPointer end program RemappingTest ]$ gfortran --version GNU Fortran (GCC) 10.2.0 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ]$ gfortran -Wall -Wextra -fno-strict-aliasing -fwrapv -Warray-temporaries PointerRemapTest.f90 PointerRemapTest.f90:13:20: 13 | call SetPointer ( B_2D, 4, 4, 3, B_3D ) | 1 Warning: Creating array temporary at (1) [-Warray-temporaries] ]$ ./a.out B_2D = -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 -3.40282347E+38 It seems to be issue is because inside the subroutine SetPointer, a new array `C_2D` is created. So `C_3D` points to this new array instead. Outside of subroutine, this pointer (now `B_3D`) actually points to an invalid memory location. In some cases I can trigger a segfault with the code with GCC-10.2.0
next reply other threads:[~2020-10-27 14:25 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-27 14:25 reubendb at gmail dot com [this message] 2020-10-27 19:07 ` [Bug fortran/97592] " anlauf at gcc dot gnu.org 2021-02-14 18:17 ` dominiq at lps dot ens.fr 2022-03-14 21:39 ` anlauf at gcc dot gnu.org 2023-03-21 19:44 ` [Bug fortran/97592] [10/11/12/13 Regression] " anlauf at gcc dot gnu.org 2023-03-21 19:57 ` anlauf at gcc dot gnu.org 2023-07-07 10:38 ` [Bug fortran/97592] [11/12/13/14 " rguenth at gcc dot gnu.org 2023-12-15 22:31 ` anlauf at gcc dot gnu.org 2023-12-16 18:29 ` anlauf at gcc dot gnu.org 2023-12-17 17:33 ` cvs-commit at gcc dot gnu.org 2023-12-27 19:27 ` cvs-commit at gcc dot gnu.org 2023-12-27 19:33 ` anlauf at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-97592-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).