https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51961 --- Comment #3 from janus at gcc dot gnu.org --- (In reply to Dominique d'Humieres from comment #1) > What is allocate supposed to do if the array and the mold are not > conformable? AFAICS the mold expr is normally only used for the type, provided the shape of the allocate-object is specified explicitly, as in Tobias' example: allocate (a(2), mold=b) ! Valid - but not accepted I tend to agree that this might be valid. Then 'a' should be allocated with two elements and using the type from 'b'. However, if the shape is not specified explicitly, then it can be taken from the source-expr (therefore the rank needs to agree) as in this example: allocate (a, mold=b) ! correctly rejected? From F08 section 18.104.22.168: When an ALLOCATE statement is executed for an array with no allocate-shape-spec-list, the bounds of source-expr determine the bounds of the array. Subsequent changes to the bounds of source-expr do not affect the array bounds. I would conclude that this second case is invalid, however this is not reflected in C638, which might possibly be an oversight in Fortran 2008. AFAICS Fortran 2018 changes nothing in this regard.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51961 Dominique d'Humieres changed: What|Removed |Added Status|NEW |WAITING CC||janus at gcc dot gnu.org --- Comment #2 from Dominique d'Humieres --- > What is allocate supposed to do if the array and the mold are not > conformable? No answer after more than six years!-(Shall I close the PR as INVALID to get one?).
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51961 Dominique d'Humieres dominiq at lps dot ens.fr changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2013-01-08 Ever Confirmed|0 |1 --- Comment #1 from Dominique d'Humieres dominiq at lps dot ens.fr 2013-01-08 15:37:02 UTC --- What is allocate supposed to do if the array and the mold are not conformable? From the 2008 draft: Data usage and computation: A structure constructor can omit the value for an allocatable component. SOURCE= in an ALLOCATE statement can give an array variable the bounds as well as the value of an expression. MOLD= in an ALLOCATE statement can give a polymorphic variable the shape, ^ type,and type parameters of an expression without copying the value. The real and imaginary parts of a complex entity can be accessed independently with a component-like syntax. Intrinsic assignment to an allocatable polymorphic variable is allowed. A pointer function reference can denote a variable in any variable definition context. Some restrictions on the use of dummy arguments in elemental subprograms have been removed.