Summary: | [8 Regression] [F08] wrong-code problem with POINTER, INTENT(IN) argument | ||
---|---|---|---|
Product: | gcc | Reporter: | Laurent Pointal <laurent.pointal> |
Component: | fortran | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | janus, tkoenig |
Priority: | P3 | Keywords: | wrong-code |
Version: | 8.3.0 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Known to work: | 5.5.0, 6.5.0, 7.3.0, 9.0 | |
Known to fail: | 8.2.0 | Last reconfirmed: | 2019-03-28 00:00:00 |
Bug Depends on: | |||
Bug Blocks: | 39627 | ||
Attachments: | Test case with pointer to 1D array |
Note: compiled with -std=f2008 option. I can confirm this problem. Reduced test case: PROGRAM testfortran2 IMPLICIT NONE INTEGER, DIMENSION(10), TARGET :: i4array i4array = (/ 1,2,3,4,5,6,7,8,9,10 /) call InRef(i4array) CONTAINS subroutine InRef(v) INTEGER, DIMENSION(:), POINTER, INTENT(in) :: v INTEGER :: i DO i=1, SIZE(v,1) WRITE(*,*) v(i) END DO END subroutine END This gives the correct output with all gfortran versions I tried (including trunk and 7.3), except 8.2, which prints: 1 1 1 1 1 1 1 1 1 1 Note that the test case is invalid in Fortran 2003: 8 | call InRef(i4array) | 1 Error: Fortran 2008: Non-pointer actual argument at (1) to pointer dummy āvā This has been fixed between revisions r264810 (2018-10-03, wrong code) and r264951 (2018-10-09, OK) and the fix has not been back ported to the GCC8 branch). I did not find any obvious commit in this range. On the GCC8 branch I see the expected output up to r251946, but a segfault at runtime for r251980 (2017-09-11), likely r251949. AFAICT the wrong code issue appeared at revision r257065. I see correct execution with 8.3.1 20190310, so I assume this has been fixed in the meantime. I will commit a test case so this does not regress. Author: tkoenig Date: Sat Mar 30 13:41:10 2019 New Revision: 270034 URL: https://gcc.gnu.org/viewcvs?rev=270034&root=gcc&view=rev Log: 2019-03-30 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/89866 * gfortran.dg/pointer_intent_8.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/pointer_intent_8.f90 Modified: trunk/gcc/testsuite/ChangeLog Author: tkoenig Date: Sat Mar 30 13:45:47 2019 New Revision: 270035 URL: https://gcc.gnu.org/viewcvs?rev=270035&root=gcc&view=rev Log: 2019-03-30 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/89866 * gfortran.dg/pointer_intent_8.f90: New test. Added: branches/gcc-8-branch/gcc/testsuite/gfortran.dg/pointer_intent_8.f90 Modified: branches/gcc-8-branch/gcc/testsuite/ChangeLog So, fixed. Thanks for the bug report! |
Created attachment 46041 [details] Test case with pointer to 1D array In gfortran 8.3, one dimension array of integers, passed as pointer argument, incorrectly managed when accessing content (only access first item). Same code of InRef_i4_1d() function (see attachement) compiled with gfortran 7.3 and gfortran 8.3 provides different output, with a bug in gfortran 8.3: ----- Compilation with: GNU Fortran (GCC) 8.3.0 ----- Test: InRef_i4_1d item 1: inrefint1d = [1 1 1 1 1 1 1 1 1 1 ] 1 1 1 1 1 1 1 1 1 1 ----- Compilation with: GNU Fortran (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 ----- Test: InRef_i4_1d item 1: inrefint1d = [1 2 3 4 5 6 7 8 9 10 ] 1 2 3 4 5 6 7 8 9 10 Note: attachement has been extracted from larger code to show the problem. A+ L.Pointal.