[Bug fortran/57590] [OOP] wrong code with class variables of different shapes
janus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Aug 20 15:06:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57590
--- Comment #10 from janus at gcc dot gnu.org ---
(In reply to Mikael Morin from comment #9)
> (In reply to janus from comment #8)
> > Error: Assumed shape array at (1) must be a dummy argument
>
> I suppose s/AS_ASSUMED_SHAPE/AS_DEFERRED/ would do for this case
That makes more sense anyway. I always get a bit confused by the
'assumed'/'deferred' nomenclature in the Fortran standard.
> but the problem remains the same: the original array spec is lost.
Yes, however any CLASS variable must be an allocatable, pointer or dummy. For
the first two, the shape must be deferred anyway.
One remaining problem here is that with the AS_DEFERRED patch, the following is
not rejected (as was the case before):
type :: t
end type
class(t), dimension(3), pointer :: c3
end
With unpatched trunk one gets:
class(t), dimension(3), pointer :: c3
1
Error: Array pointer 'c3' at (1) must have a deferred shape or assumed rank
This check would need to be done before building the class container. Further
problems can appear with dummies. Here is a variant of comment 0:
type t
end type t
type(t) :: b(2)
call s3(b)
contains
subroutine s3(a)
class(t), dimension(3) :: a
print *, shape(a)
end subroutine s3
end
However, one doesn't get any warning or error here (neither with nor without
the patch). With a type(t) dummy, one gets:
call s3(b)
1
Warning: Actual argument contains too few elements for dummy argument 'a' (2/3)
at (1)
More information about the Gcc-bugs
mailing list