Investors & landlords

If the amount of the loss is added to the cost basis of the remaining shares, then what if you sell all 100 shares at a loss and there are no remaining shares with a cost basis to add the amount of the loss to?  Where does it go?