I filed a ticket and was told that this is documented in perlxs.
This is quite useful as it usually improves readability. While
this works fine for an SV *, it's unfortunately not as easy
to have AV * or HV * as a return value. You should be
able to write:
AV *
array()
CODE:
RETVAL = newAV();
/* do something with RETVAL */
OUTPUT:
RETVAL
But due to an unfixable bug (fixing it would break lots of existing
CPAN modules) in the typemap file, the reference count of the AV *
is not properly decremented. Thus, the above XSUB would leak memory
whenever it is being called. The same problem exists for HV *.