This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]