I don't know if it's ever been litigated, but you are allowed to make a copy of music on a CD that you own. One would surmise that when you no longer own the CD, you no longer have a valid license for that recording. I think you would have a stronger argument if you simply discarded the CDs as you never transferred your license, but if you sell that CD then your license goes with the physical medium.
See this and the comments below (especially the one from the lawyer):
Way down in this thread is another comment by an actual IP lawyer:
So, who knows? Thus, this emoticon:
After a few google searches, it looks like it is illegal to buy/rip/sell cds.
It's even illegal to destroy or giveaway cds without deleting all digital copies of the music after the cd is no longer in your possession.