At the time I wrote my original comments, I was going off memory without reading the actual source code. Now that I look at it again, I realise that a slightly more sophisticated fix is required, first see if m will fit into an octave_idx_type, and if it doesn't then force a short shuffle.

It's a bit more than a one-liner right now, and at the moment I can't dedicate any time to this possibly easy problem.