* [Bug fortran/35040] usage of init expression in its own definition
2008-01-31 10:43 [Bug fortran/35040] New: usage of init expression in its own definition dfranke at gcc dot gnu dot org
@ 2008-01-31 12:46 ` burnus at gcc dot gnu dot org
2008-01-31 13:30 ` burnus at gcc dot gnu dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-01-31 12:46 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from burnus at gcc dot gnu dot org 2008-01-31 12:22 -------
I think this is valid. One has to read carefully what specification-part and
entity-decl means. I think after "integer(8)" the kind is known and in the next
specification part (e.g. for the dimension) one may use it; similar for your
example: After the bounds are known in the specification (i.e. before "::") one
may use it in the entry decl.
However, the following is circular and thus invalid:
REAL(8), PARAMETER :: xyz(size(xyz)) = 1
which is rejected by NAG f95:
Error: Shape enquiry on PARAMETER XYZ before its array declarator is complete
but gfortran wrongly accepts it.
I wonder whether the following is valid or not:
REAL(8), dimension(kind(xyz)) :: xyz
NAG f95 and gfortran say yes, ifort says no.
That dimension depends on the kind is ok, the problem is whether one may
already use "xyz" or not.
>From "7.1.7 Initialization expression" (F2003):
"If an initialization expression includes a specification inquiry that depends
on a type parameter or an array bound of an entity specified in the same
specification-part, the type parameter or array bound shall be specified in a
prior specification of the specification-part. The prior specification may be
to the left of the specification inquiry in the same statement, but shall not
be within the same entity-decl."
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35040
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/35040] usage of init expression in its own definition
2008-01-31 10:43 [Bug fortran/35040] New: usage of init expression in its own definition dfranke at gcc dot gnu dot org
2008-01-31 12:46 ` [Bug fortran/35040] " burnus at gcc dot gnu dot org
@ 2008-01-31 13:30 ` burnus at gcc dot gnu dot org
2008-01-31 22:52 ` burnus at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-01-31 13:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from burnus at gcc dot gnu dot org 2008-01-31 12:39 -------
I asked at comp.lang.fortran:
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/a05b8b177f2eb7b1/
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35040
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/35040] usage of init expression in its own definition
2008-01-31 10:43 [Bug fortran/35040] New: usage of init expression in its own definition dfranke at gcc dot gnu dot org
2008-01-31 12:46 ` [Bug fortran/35040] " burnus at gcc dot gnu dot org
2008-01-31 13:30 ` burnus at gcc dot gnu dot org
@ 2008-01-31 22:52 ` burnus at gcc dot gnu dot org
2008-02-01 9:48 ` dfranke at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-01-31 22:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from burnus at gcc dot gnu dot org 2008-01-31 22:25 -------
Answer (see link): All these are wrong per answer to an interpretation request:
6. INTEGER :: B = BIT_SIZE(B)
7. INTEGER :: B(BIT_SIZE(B))
8. INTEGER :: D = DIGITS(D)
9. INTEGER :: D(DIGITS(D))
10. REAL :: X = EPSILON(X)
2. INTEGER(selected_int_kind(4)) :: A(KIND(A)) 3. INTEGER ::
A(2,2*SIZE(A,1)+1) 4. CHARACTER :: C(10)*(SIZE(C,1)) 5. INTEGER ::
P(10) = LBOUND(P,1)
1. INTEGER :: P(complicated_expression_for_lower_bound_1: &
& complicated_expression_for_upper_bound_1, &
& complicated_expression_for_lower_bound_2: &
& complicated_expression_for_upper_bound_2) = &
& RESHAPE( (/ 11, 21, 12, 22 /), SHAPE(P) )
And I also believe all our examples in this PR are wrong. While we really have
to reject
REAL(8), PARAMETER :: xyz(size(xyz)) = 1
we could allow the others as extension (i.e. only reject using -std=f*) - or we
reject them all.
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2008-01-31 22:25:49
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35040
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/35040] usage of init expression in its own definition
2008-01-31 10:43 [Bug fortran/35040] New: usage of init expression in its own definition dfranke at gcc dot gnu dot org
` (2 preceding siblings ...)
2008-01-31 22:52 ` burnus at gcc dot gnu dot org
@ 2008-02-01 9:48 ` dfranke at gcc dot gnu dot org
2008-11-01 21:20 ` janus at gcc dot gnu dot org
2008-11-01 22:15 ` burnus at gcc dot gnu dot org
5 siblings, 0 replies; 9+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2008-02-01 9:48 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from dfranke at gcc dot gnu dot org 2008-02-01 09:47 -------
> And I also believe all our examples in this PR are wrong.
In all the invalid examples given in comment #3, the dimension specification is
on the rhs of '::'. In my example it's on the lhs. If the latter is invalid
too, how about
DIMENSION :: xyz(2,2)
REAL, PARAMETER :: xyz = RESHAPE((/ 1,2,3,4 /), SHAPE(xyz))
END
This should be perfectly valid?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35040
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/35040] usage of init expression in its own definition
2008-01-31 10:43 [Bug fortran/35040] New: usage of init expression in its own definition dfranke at gcc dot gnu dot org
` (3 preceding siblings ...)
2008-02-01 9:48 ` dfranke at gcc dot gnu dot org
@ 2008-11-01 21:20 ` janus at gcc dot gnu dot org
2008-11-01 22:15 ` burnus at gcc dot gnu dot org
5 siblings, 0 replies; 9+ messages in thread
From: janus at gcc dot gnu dot org @ 2008-11-01 21:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from janus at gcc dot gnu dot org 2008-11-01 21:19 -------
On a related note: The following snippet from PR36426 produces an ICE.
function foo(x)
character(len=len(x)) :: foo,x
end function foo
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35040
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/35040] usage of init expression in its own definition
2008-01-31 10:43 [Bug fortran/35040] New: usage of init expression in its own definition dfranke at gcc dot gnu dot org
` (4 preceding siblings ...)
2008-11-01 21:20 ` janus at gcc dot gnu dot org
@ 2008-11-01 22:15 ` burnus at gcc dot gnu dot org
5 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-11-01 22:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from burnus at gcc dot gnu dot org 2008-11-01 22:14 -------
(In reply to comment #5)
> On a related note: The following snippet from PR36426 produces an ICE.
> function foo(x)
> character(len=len(x)) :: foo,x
> end function foo
As this ICE is a regression, I opened the PR 37992 for this. (It is also not an
accepts invalid since gfortran 4.4 now prints an error message.)
* * *
For the LHS (of "=") expressions such as in comment 1, one now also gets the
error message.
* * *
(In reply to comment #4)
> > And I also believe all our examples in this PR are wrong.
> In all the invalid examples given in comment #3, the dimension specification
> is on the rhs of '::'. In my example it's on the lhs.
Sorry, I don't understand / find your example. The example
REAL, DIMENSION(2,2), PARAMETER :: xyz = RESHAPE((/ 1,2,3,4 /), SHAPE(xyz))
is no different from the invalid examples of comment #3:
REAL :: X = EPSILON(X)
> If the latter is invalid too, how about
> DIMENSION :: xyz(2,2)
> REAL, PARAMETER :: xyz = RESHAPE((/ 1,2,3,4 /), SHAPE(xyz))
I think that test case is OK.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35040
^ permalink raw reply [flat|nested] 9+ messages in thread