Bug 27786 - [4.1 only] Bad interaction between Cray pointer, assumed-size array and bounds checking
Summary: [4.1 only] Bad interaction between Cray pointer, assumed-size array and bound...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Asher Langton
URL:
Keywords: patch
Depends on:
Blocks: Fortran_bounds_checking
  Show dependency treegraph
 
Reported: 2006-05-28 13:52 UTC by Francois-Xavier Coudert
Modified: 2006-06-15 23:11 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.2.0
Known to fail: 4.1.2
Last reconfirmed: 2006-05-29 07:44:54


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Francois-Xavier Coudert 2006-05-28 13:52:22 UTC
This reduced testcase is originally from the testsuite gfortran.dg/cray_pointers_2.f90. It generates an incorrect out-of-bounds error message when run with bounds-checking enabled.

$ cat cray_pointers_2.f90 
  integer targ(2)
  integer pte
  pointer(ptr,pte(*))
  ptr = loc(targ)

  targ(2) = -1
  print *, pte(2)
  end
$ gfortran -fbounds-check -fcray-pointer cray_pointers_2.f90 && ./a.out
Fortran runtime error: Array reference out of bounds
Comment 1 Andrew Pinski 2006-05-29 07:44:54 UTC
Confirmed.
Comment 2 patchapp@dberlin.org 2006-05-31 12:45:28 UTC
Subject: Bug number PR 27786

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-05/msg01544.html
Comment 3 Asher Langton 2006-06-08 21:01:07 UTC
Subject: Bug 27786

Author: langton
Date: Thu Jun  8 21:00:26 2006
New Revision: 114495

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114495
Log:
	* cray_pointers_2.f90: Add -fbounds-check compile flag.

	PR fortran/27786
	* trans-array.c (gfc_conv_array_ref): Eliminate bounds checking
	for assumed-size Cray pointees.


Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/cray_pointers_2.f90

Comment 4 Asher Langton 2006-06-08 21:03:54 UTC
I've committed a patch that should fix this bug.
Comment 5 Francois-Xavier Coudert 2006-06-09 06:43:17 UTC
I'm reopening the PR because the bug is not fixed yet on the 4.1 branch. The current policy is to allow a week before comitting your patch to 4.1 (after bootstrap & regtesting), and then close the bugzilla PR.

(in case you need info on how to use svn to backport a patch, you can read http://gcc.gnu.org/wiki/SvnMerge)
Comment 6 Asher Langton 2006-06-15 23:07:26 UTC
Subject: Bug 27786

Author: langton
Date: Thu Jun 15 23:07:14 2006
New Revision: 114692

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114692
Log:
        PR fortran/27786
        * cray_pointers_2.f90: Add -fbounds-check compile flag.

        PR fortran/27786
        * trans-array.c (gfc_conv_array_ref): Eliminate bounds checking
        for assumed-size Cray pointees.


Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/trans-array.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/cray_pointers_2.f90

Comment 7 Asher Langton 2006-06-15 23:11:25 UTC
I've backported the patch to 4.1, so this bug should be resolved.