From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8702 invoked by alias); 16 Jun 2009 08:19:52 -0000 Received: (qmail 8652 invoked by uid 48); 16 Jun 2009 08:19:36 -0000 Date: Tue, 16 Jun 2009 08:19:00 -0000 Message-ID: <20090616081936.8651.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/40452] -fbounds-check: False positive due to ignoring storage association In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "burnus at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-06/txt/msg01016.txt.bz2 ------- 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