What happens to the transaction using the coinbase transaction output of a block later considered stale?
Found the answer on Bitcoin Wiki short after.


  The reward for the blocks on the shorter chain will not be present in the longest chain, so they will be practically lost, which is why a network-enforced 100-block maturation time for generations exists.


Since practically no fork can survive longer than 10 block. This enforcement could prevent the scenario described in the question to happen in the first place.