Re: Allocatable arrays in derived types



relaxmike <michael.baudin@xxxxxxxxx> wrote:

I don't remember exactly where I read it on this forum,
but I remember that the difference between allocatable and pointer
arrays is that, when an allocatable array goes out of scope,
it is automatically deallocated.

That is *A* difference. It is certainly not *THE* difference.

This is the main reason for the overhead of a allocatable
array

No. That has pretty much nothing to do with it. Indeed, the size
overhead of an alocatable array is typically the same as that for a
pointer array.

there is also an additional bookkeeping
for the derived type itself ?

Not typically. There can be padding in some cases.

And what if one computes directly the size of the allocatable
array ? I expect it to be 1, but is that true ?

No. One would actiually have a bit of trouble computing such a thing (I
assume you mean the size of the descriptor or some such thing). If you
did, it would more likely be the same as that of the component. A single
integer is "clearly" insufficient to store the necessary data, which at
a minimum for a rank 1 array is the lower bound, size, and memory
location.

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



Relevant Pages

  • Re: char **argv & char *argv[]
    ... "pointer to pointer to char". ... >> pointer)) pointing to the first element of an array. ... so we have to start adding more context. ... type "pointer to char", rather than "array MISSING_SIZE of char". ...
    (comp.lang.c)
  • Re: why cannot assign to function call
    ... hypothetical C-like languages, ... sizeof business would still indicate that a pointer was being passed. ... talk about variables of an array type. ... the earlier version of the standard didn't have numbered ...
    (comp.lang.python)
  • Re: multi dimensional arrays as one dimension array
    ... please - where does the standard say that such a conversion ... Pointer conversion yields a pointer to the same object as ... exist only where there are array declarations. ...
    (comp.lang.c)
  • Re: Evaluating unary *
    ... 'arr' exists, ... value can be used with the same syntax as would be used to access a 2D array of the kind you're referring to, but that 2D array is just a different way of looking as the same object that was already created by the definition of 'arr'. ... to me, it makes sense to return a pointer to the first value of an array, but to return the address of the pointer to the first value of an array, is not directly possible as such. ... lea eax, ...
    (comp.std.c)
  • Re: "Mastering C Pointers"....
    ... A pointer is a kind of variable that can "point to" some object. ... has a type (pointer to int), and a value of some kind. ... You may know that you can access these integers by using array notation ... The function will take one argument, a string, and will return the length ...
    (comp.lang.c)