SDL_BlitSurface with same source and dest

Is it legal to blit to and from the same surface, as long as the source and
destination areas don’t overlap? SDL’s behavior seems inconsistent.

I wrote a simple program to fill areas of a surface with a checkerboard
pattern of 2 colors:
It does this:

  1. Sets clip rect to allowed area
  2. Draws a pattern of 4 squares in the upper left with SDL_FillRect’s
  3. While it’s narrower than the area, blit it right of and double width
  4. While it’s shorter than the area, blit it below itself and double height

Usually this works great, but in circumstances that seem to be painfully
difficult to reduce to a simple example, it only draws the upper left
rectangle – nothing else appears. I have confirmed that it actually is
doing all the blitting it’s supposed to when this happens – the blits just
don’t “take”.

Is this supposed to work, or am I relying on undefined behavior by using the
same source and destination surface?