[Bug fortran/40452] -fbounds-check: False positive due to ignoring storage association

2010-06-04 Thread tkoenig at gcc dot gnu dot org


--- Comment #5 from tkoenig at gcc dot gnu dot org  2010-06-04 07:15 ---
Can we close this?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40452



[Bug fortran/40452] -fbounds-check: False positive due to ignoring storage association

2010-06-04 Thread burnus at gcc dot gnu dot org


--- Comment #6 from burnus at gcc dot gnu dot org  2010-06-04 12:22 ---
Yes, we can CLOSE the bug as FIXED.


-- 

burnus at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40452



[Bug fortran/40452] -fbounds-check: False positive due to ignoring storage association

2009-06-20 Thread burnus at gcc dot gnu dot org


--- Comment #4 from burnus at gcc dot gnu dot org  2009-06-20 18:07 ---
Subject: Bug 40452

Author: burnus
Date: Sat Jun 20 18:07:10 2009
New Revision: 148750

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=148750
Log:
2009-06-20  Tobias Burnus  bur...@net-b.de

PR fortran/40452
* trans-decl.c (add_argument_checking): Disable bounds check
for allowed argument storage association.

2009-06-20  Tobias Burnus  bur...@net-b.de

PR fortran/40452
* gfortran.dg/bounds_check_strlen_9.f90: New test.


Added:
trunk/gcc/testsuite/gfortran.dg/bounds_check_strlen_9.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-decl.c
trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40452



[Bug fortran/40452] -fbounds-check: False positive due to ignoring storage association

2009-06-18 Thread burnus at gcc dot gnu dot org


--- Comment #3 from burnus at gcc dot gnu dot org  2009-06-18 09:00 ---
Patch: http://gcc.gnu.org/ml/fortran/2009-06/msg00188.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40452



[Bug fortran/40452] -fbounds-check: False positive due to ignoring storage association

2009-06-16 Thread burnus at gcc dot gnu dot org


--- Comment #1 from burnus at gcc dot gnu dot org  2009-06-16 08:19 ---
(In reply to comment #0)
 The challenge is diagnose this properly. The problem is that the array size is
 _not_ passed. One solution would be to enable the check only with -std=f95.

And for scalar dummy arguments: As one may not pass an array (section) actual
argument to a scalar dummy argument, that should work.

TODO 1: Confirm that the argument storage association is indeed new in F2003
and decide whether the result of -fbounds-check should really depend on
-std=f95.

TODO 2: Check whether the -std=f95 dependence should be noted somehow in the
-fcheck section of invoke.texi.

TODO 3: Add test cases - one with -fno-whole-file ;-)

Draft patch (sorry, tabs don't paste):

Index: trans-decl.c
===
--- trans-decl.c(revision 148518)
+++ trans-decl.c(working copy)
@@ -3835,7 +3835,11 @@ add_argument_checking (stmtblock_t *bloc

/* For POINTER, ALLOCATABLE and assumed-shape dummy arguments, the
   string lengths must match exactly.  Otherwise, it is only required
-  that the actual string length is *at least* the expected one.  */
+  that the actual string length is *at least* the expected one.
+  Fortran 2003 allows for argument storage association thus for the
+  latter case we only add the test for -std=f95 or if the dummy
+  argument is not an array, which implies that the actual argument
+  is also a scalar.  */
if (fsym-attr.pointer || fsym-attr.allocatable
|| (fsym-as  fsym-as-type == AS_ASSUMED_SHAPE))
  {
@@ -3843,6 +3847,9 @@ add_argument_checking (stmtblock_t *bloc
message = _(Actual string length does not match the declared one
 for dummy argument '%s' (%ld/%ld));
  }
+   else if ((fsym-as  fsym-as-rank != 0)
+ (gfc_option.allow_std  GFC_STD_F2003) != 0)
+ continue;
else
  {
comparison = LT_EXPR;


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40452



[Bug fortran/40452] -fbounds-check: False positive due to ignoring storage association

2009-06-16 Thread burnus at gcc dot gnu dot org


--- Comment #2 from burnus at gcc dot gnu dot org  2009-06-16 21:32 ---
Wrong quote - and wrong statement. It is not a F2003 change, but already in
F95.

Fortran 95 has (12.4.1.4 Sequence association)

If the actual argument is of type default character and is an array
 expression, array element, or array element substring designator, the
 element sequence consists of the character storage units beginning with
 the first storage unit of the actual argument and continuing to the end
 of the array. The character storage units of an array element substring
 designator are viewed as array elements consisting of consecutive groups
 of character storage units having the character length of the dummy
 array.

Fortran 2003 has in 12.4.1.5 the same (except of allowing C_CHAR) and
then continues with

If the actual argument is of type default character or of type character
 with the C character kind, and is a scalar that is not an array element
 or array element substring designator, the element sequence consists of
 the storage units of the actual argument.

(The addition is not important for us, but it allows to pass a string
 to a BIND(C) procedure which has character(len=1):: str(*).)

 * * *

The crucial part is the dummy array at the end of the first excerpt.


-- 

burnus at gcc dot gnu dot org changed:

   What|Removed |Added

 AssignedTo|unassigned at gcc dot gnu   |burnus at gcc dot gnu dot
   |dot org |org
 Status|UNCONFIRMED |ASSIGNED
 Ever Confirmed|0   |1
   Last reconfirmed|-00-00 00:00:00 |2009-06-16 21:33:00
   date||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40452