https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125610
--- Comment #2 from Harald Anlauf <anlauf at gcc dot gnu.org> ---
It works with TYPE:
function foo_factory_1_(i) result(foo)
integer, intent(in) :: i(:)
type(foo_t), allocatable :: foo(:)
...
instead of CLASS.
