Yes, this piece of code does not compile in gfortran.
And this works in gfortran.
I have just read the code of an XML library (xml-fortran/tree_struct.f90 in paulromano/xml-fortran). It uses pointer instead of allocatable attribute. So I tried a pointer implementation for the code I posted, and it compiles in gfortran. I think it might be a feasible way too, although I am less willing to use pointer in general.