(j3.2006) C629
Malcolm Cohen
malcolm
Thu May 29 00:38:05 EDT 2014
Yes, I think so. Removing the requirement makes leaving off the type-spec an
easy mistake to make (likely to result in memory overwrites later, and not
detected if compiling without checking).
Given
CHARACTER(10),POINTER :: x
CHARACTER(:),POINTER :: y
one expects
ALLOCATE( name )
to have the same effect as
ALLOCATE( typespec :: name )
where typespec ***is the typespec in the declaration of name***, not some random
different typespec with the same type but one or more type parameters different.
Thus
ALLOCATE( x )
acts as a CHARACTER(10) allocation, and
ALLOCATE( y )
acts as a CHARACTER(:) allocation, which is not allowed since ":" is not a
value, i.e. you get an error message. Just because
CHARACTER z
has a default LEN=1 for declaration purposes does not mean
CHARACTER(:) y
should mean "LEN=1" for non-declaration purposes, and in fact it doesn't. It
means you have to provide something that specifies it. Not providing anything
is different from "providing something". If you really do want the "default if
you did not specify LEN" then
ALLOCATE( CHARACTER :: y )
is available, and here you have told the compiler "yes, I really do want the
default for declarations even though I wasn't declaring anything".
Cheers,
-----Original Message-----
From: Van Snyder
Date: ?? 26?5?29? 11:06
To: j3
Subject: (j3.2006) C629
C629 says that if an <allocate-object> has a deferred type parameter,
either <type-spec> or <source-expr> shall appear.
Is that really necessary if the type parameter has a default value?
_______________________________________________
J3 mailing list
J3 at mailman.j3-fortran.org
http://mailman.j3-fortran.org/mailman/listinfo/j3
________________________________________________________________________
This e-mail has been scanned for all viruses by Star.
________________________________________________________________________
--
................................Malcolm Cohen, Nihon NAG, Tokyo.
More information about the J3
mailing list