Bug 33689 - [Regression 4.3] Array with constant bound rejected as automatic array
Summary: [Regression 4.3] Array with constant bound rejected as automatic array
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Tobias Schlüter
URL:
Keywords: rejects-valid
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2007-10-08 09:02 UTC by Tobias Burnus
Modified: 2007-10-08 22:10 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.2.1 4.1.3
Known to fail: 4.3.0
Last reconfirmed: 2007-10-08 18:25:27


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2007-10-08 09:02:48 UTC
The following program is valid and compiles with GCC 4.2.x. However, using today's 4.3.0 it is rejected with the message:

    REAL, save :: c(0:(lmaxd+1)*(lmaxd+1))
                                         1
Error: automatic object 'c' at (1) cannot have the SAVE attribute

Obviously, 'C' is not an automatic object but has constant bounds and can thus have the SAVE attribute.

  subroutine grylmr()
    integer, parameter :: lmaxd = 20
    REAL, save :: c(0:(lmaxd+1)*(lmaxd+1))
  end subroutine grylmr
end
Comment 1 Tobias Burnus 2007-10-08 09:07:37 UTC
Fails:
  2007-10-08-r129121
Works:
  2007-09-27-r128828

Comment 2 Dominique d'Humieres 2007-10-08 10:11:22 UTC
works with revision 129038 (20071005).
Comment 3 Tobias Burnus 2007-10-08 17:58:35 UTC
Works: r129068; fails: r129069.

http://gcc.gnu.org/ml/gcc-cvs/2007-10/msg00174.html

r129069 | tobi | 2007-10-07 13:45:15 +0200 (So, 07 Okt 2007) | 14 lines

PR 20851
fortran/
* expr.c (check_inquiry): Typo fix in error message.
(check_init_expr): Same * 3.
(check_restricted): Verify that no dummy arguments appear in
restricted expressions in ELEMENTAL procedures.
* resolve.c (resolve_fl_variable): Exchange order of checks to
avoid side-effect.
Comment 4 Tobias Schlüter 2007-10-08 18:02:07 UTC
Subject: Re:  [Regression 4.3] Array with constant bound
 rejected as automatic array

burnus at gcc dot gnu dot org wrote:
> ------- Comment #3 from burnus at gcc dot gnu dot org  2007-10-08 17:58 -------
> Works: r129068; fails: r129069.
> 
> http://gcc.gnu.org/ml/gcc-cvs/2007-10/msg00174.html
> 
> r129069 | tobi | 2007-10-07 13:45:15 +0200 (So, 07 Okt 2007) | 14 lines
> 
> PR 20851
> fortran/
> * expr.c (check_inquiry): Typo fix in error message.
> (check_init_expr): Same * 3.
> (check_restricted): Verify that no dummy arguments appear in
> restricted expressions in ELEMENTAL procedures.
> * resolve.c (resolve_fl_variable): Exchange order of checks to
> avoid side-effect.
> 
> 
Just great, looks like we were relying on a side-effect before.

I'll have a look.
Comment 5 Tobias Schlüter 2007-10-08 18:25:27 UTC
I think I have a fix.  Needs some more testing, though.
Comment 6 patchapp@dberlin.org 2007-10-08 20:26:43 UTC
Subject: Bug number PR33689

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/2007-10/msg00439.html
Comment 7 Tobias Schlüter 2007-10-08 20:54:59 UTC
Subject: Bug 33689

Author: tobi
Date: Mon Oct  8 20:54:47 2007
New Revision: 129139

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129139
Log:
PR fortran/33689
fortran/
* resolve.c (gfc_resolve_expr): Fix indentation.
(resolve_fl_variable_derived): Rename argument.
(resolve_fl_variable): Fix case in message.  Clarify logic.
Correctly simplify array bounds.
testsuite/
* gfortran.dg/spec_expr_5.f90: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/spec_expr_5.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog

Comment 8 Tobias Schlüter 2007-10-08 22:10:12 UTC
Fixed.