Hi Tobias, you are right in that I was barking up the wrong tree. I was focussed too much on the testcase in the PR. > I think that one is wrong. While CLASS_DATA (e) accesses e->ts.u.derived->components, > which always works, your code assumes that there is only 'c' and not 'x%c' where > 'c' is of type BT_CLASS and 'x' is of type BT_DERIVED. > > I wonder whether it works if you simply remove 'return true;' > as gfc_add_class_array_ref sets 'e->rank = CLASS(e)->rank (and > adds an AR_FULL ref, if needed). In the nonerror case, the > 'return true' is obtained via: > if (e->rank != 0 && e->ts.type != BT_PROCEDURE) > return true; > And, otherwise, it falls through to the error. > > OK if that works Well, I tried and this does not work. However, an additional plain check on e->rank != 0 also in the CLASS cases fixes the original issue as well as your example: > type t > class(*), allocatable :: c(:) > end type t > type(t) :: x > x%c = [1,2,3,4] > print *, size(x%c) > print *, size(x%c(1)) ! { dg-error ... } > end And regtests ok. :-) See attached updated patch. Anything else I am missing? Thanks for the constructive review! Harald