Move an assertion so it doesn't dereference end().

The R600 target has test cases that exercises this code.