Re: allocatable components and TRANSFER behavior

glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx> wrote:

Richard Maine <nospam@xxxxxxxxxxxxx> wrote:

No. Its a bit tricky to work through the exact words that say no, but
I'm convinced they are there. Transfer is just about copying bits.
Automagic allocation is not just copying bits.

It doesn't seem so obvious to me. Separate from the copy bits
question, allocate on assignment (that is what I thought was
being asked) is a property of the assignment. How about:

v2 = transfer(tempv, v1) + 1

Now the expression has to be evaluated before the assignment.

It has nothing to do with the assignment. The transfer itself is what
has the problem. And, as usual, you are thinking to much about
implementation issues. This is most definitely a question about the
standard - not about what an implementation is likely to do. As
described by the standard, the RHS is *ALWAYS* evaluated before the
assignment. Anything ese is an optimization. While your +1 might change
the odds of an implementation optimizing things, it does not change what
the standard says about it.

The transfer itself gives a copy of the "physical representation". The
descriptor is part of that physical representation". If the transfer
allocated memory elsewhere and made the descriptor point to that new
memory, then the result would not have the same physical representation.
See also the description of what happens to allocatable components of
function results. They are deallocated after the statement completes.
That's going to be a problem here.

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

Relevant Pages

  • Re: [RFC PATCH] type safe allocator
    ... and matching up the size of the allocation with the type ... the information about target of pointer to the resulting void *; ... (assignment, passing argument to function, initializer, return) ... anything that doesn't look like a normal function call with normal arguments ...
  • Re: Defined assignment and allocation on assignment
    ... lhs = REPEAT ... END SUBROUTINE assign_udt_to_char ... Defined assignment is really just cute syntax for a CALL statement. ... Then you will get allocation on assignment from the ...
  • Re: How can I freeze allocation %?
    ... You're allocating a resource to production support for a year. ... I am scheduled 4 hours per day each, 50% assignment, on tasks A and B over a ... Task A is fixed duration. ... Project shows a new allocation of 75% on ...
  • Re: How can I freeze allocation %?
    ... Project is about scheduling and tracking project work, ... *peak* allocation might change to 50% because that's what she did 4 ... > assignment, you are ...
  • Re: Use of deferred type parameter and ALLOCATE
    ... Besides the feature of allowing allocation of character length at all, ... allocation on assignment. ... < point of just always doing a reallocation anyway. ... and returns the new pointer (or NULL ...