Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Strange error with type-spec

6 views
Skip to first unread message

James Van Buskirk

unread,
Jan 23, 2011, 11:42:01 AM1/23/11
to
Consider the following example:

C:\gfortran\opengl\ext>type bug1.f90
program bug1
implicit none
integer s,e
character(80) L

L = 'this that and the other thing'
s = index(L,'that')
e = s+scan(L(s:),' ')-2
write(*,'(a)') L(s:e)//'#'
! if(any(L(s:e+1) == [character(e-s+2)::'that','those'])) then
! end if
call sub1(L,s,e)
call sub2(L,s,e)
end program bug1

subroutine sub1(L,s,e)
implicit none
character(*) L
integer s,e
if(any(L(s:e+1) == [character(len(L(s:e))+1)::'that','those'])) then
end if
end subroutine sub1

subroutine sub2(L,s,e)
implicit none
character(*) L
integer s,e
if(any(L(s:e+1) == [character(e-s+2)::'that','those'])) then
end if
end subroutine sub2

C:\gfortran\opengl\ext>gfortran bug1.f90 -obug1
bug1.f90:20:0: error: size of variable 'A.4' is too large
bug1.f90:28:0: error: size of variable 'A.1' is too large

I don't understand these error messages. If those two lines:

if(any(L(s:e+1) == [character(e-s+2)::'that','those'])) then
end if

are uncommented then the error message changes to:

C:\gfortran\opengl\ext>gfortran bug1.f90 -obug1
bug1.f90:10.33:

if(any(L(s:e+1) == [character(e-s+2)::'that','those'])) then
1
Error: Variable 'e' cannot appear in the expression at (1)

Which I understand but disagree with. It seems reasonable to me
that a length type parameter be a variable.

--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end


Richard Maine

unread,
Jan 23, 2011, 11:51:41 AM1/23/11
to
James Van Buskirk <not_...@comcast.net> wrote:

> if(any(L(s:e+1) == [character(e-s+2)::'that','those'])) then
> 1
> Error: Variable 'e' cannot appear in the expression at (1)
>
> Which I understand but disagree with. It seems reasonable to me
> that a length type parameter be a variable.

e being here an "ordinary" local variable. I agree with you. An
arbitrary integer expression is allowed in that context. I'm guessing
that the compiler is thinking this has to be a specification expression
because in many of the places where a type spec can appear, that is
required. But it isn't required here.

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain

Richard Maine

unread,
Jan 23, 2011, 11:54:28 AM1/23/11
to
Richard Maine <nos...@see.signature> wrote:

> James Van Buskirk <not_...@comcast.net> wrote:
>
> > if(any(L(s:e+1) == [character(e-s+2)::'that','those'])) then
> > 1
> > Error: Variable 'e' cannot appear in the expression at (1)
> >
> > Which I understand but disagree with. It seems reasonable to me
> > that a length type parameter be a variable.
>
> e being here an "ordinary" local variable. I agree with you. An
> arbitrary integer expression is allowed in that context. I'm guessing
> that the compiler is thinking this has to be a specification expression
> because in many of the places where a type spec can appear, that is
> required. But it isn't required here.

(And to elaborate on why, most places where a type spec can appear are
in declarations, which have to be evaluated before any executable code.
The fundamental idea of specification expressions is that they can be
evaluated before any executable code. But an array constuctor like this
can appear in the middle of ordinary executable code.)

glen herrmannsfeldt

unread,
Jan 23, 2011, 6:23:51 PM1/23/11
to
James Van Buskirk <not_...@comcast.net> wrote:
(snip)

> C:\gfortran\opengl\ext>gfortran bug1.f90 -obug1
> bug1.f90:20:0: error: size of variable 'A.4' is too large
> bug1.f90:28:0: error: size of variable 'A.1' is too large

> I don't understand these error messages. If those two lines:

I will guess that A.4 and A.1 are temporary variables used
by the compiler in evaluating the expression. They probably
should't appear in messages, but then what else could go there?



> if(any(L(s:e+1) == [character(e-s+2)::'that','those'])) then
> end if

-- glen

0 new messages