A quote from Wikipedia for castling rule:
the squares between the king and the rook involved are unoccupied
What if the squares are not occupied at this instance but an opponent piece was there before?
I tried on a computer chess game, it would not allow a castling move.