IANAL, but the situation is really pretty simple: it's perfectly legal to sell a CD you own, and it's perfectly legal to rip a CD that you own to your hard drive. However, if you choose to sell a CD that you've copied, it is NOT legal to retain the copy.
A CD is a physical object, but when you purchase a CD, you acquire not just a physical copy of the music, but also a license for the personal use of that music. Purchasing a CD does not, for example, allow you to use that music for the soundtrack of a commercial motion picture. That is a use not covered by the license.
If you decide to sell your CD, you sell not only the silver disk, but the personal use license that goes with it. Any copies you retain are no longer licensed, or in other words, are illegal.
Unless, of course, you are unlucky enough that the RIAA decides to make an example of you and sue you for every penny you're worth, the chances of getting caught are pretty slim. But to argue that this practice is anything but illegal, immoral and unethical is simply a self-serving rationalization.
-