TRANSFER of type with ultimate ALLOCATABLE component

nagfor is storing the parameterized array like a fixed size array, which is the behavior I would expect. It seems that nagfor is the only compiler around that correctly implements the PDTs!

Yes, and that is a shame. They have been in the language for over 20 years now (since f2003), and I have many situations where I could use them, if only they were portable among all of the popular fortran compilers (especially gfortran). There are workarounds within the language. In this case, I use allocatable components instead, but then you can’t do things like p => x(:)%a(1).

1 Like

Your test does not prove that - only that it happened to seem to work. Copying descriptor data will sometimes not reveal a problem, but other times it will.

Let me rephrase: nagfor is the only compiler among the 5 tested that doesn’t miserably fail on this very simple test code :slight_smile:

Your test depends on undefined behavior.

Where is the UB here?

I think his comment was just about the PDT code, which does not involve TRANSFER.

1 Like