WD-40 is a PENETRATING agent ...
In 1997 I bought a Kimber custom. Used it in IPSC competition. Living in Oregon, most of the year my pistols are wet when I get home and they rust easily (especially the Kimber, which had a Kimber-Crap finish.)
So when I got home from a match and didn't have time to clean it immediately, I just took the grips off and sprayed it with WD-40. I figured it would keep it from rusting, which it did. Usually, I got around to cleaning the gun with 'normal guncleaning procedures" * afer a day or two
After about a year, I took my Kimber to a gunsmithing friend for some trigger work. This required him to detail-strip the gun, instead of field-stripping which I typically do when I clean it.
His report? "Good gun, little discernible wear after 15,000 rounds ... looks like brand new except it was the dirtiest gun I've ever seen!!!!"
The WD-40 helps powder residue and incidental range crap to migrate from the outside to the inside of the frame. And yes, it does leave a residue which you can NOT get off if you don't tear the gun down to where the residue is deposite. I'm talking about the trigger mechanism, the sear spring, etc.
I've since given up on WD-40 as a firearm cleanin, moisture-protection, or preservative substance.
I use Hoppes or MP-7, even Simple Green to clean guns. Then I use an appropriate oil (whch may be synthetic automotive oil, 3-in-1 oil, or the fancy schmancy 'gun oils' that you find in gunshops) but only AFTER I have removed as much residue as possible with a de-greaser.
Hint: Brake Cleaner fluid comes in a convenient aerosol spray can, costs $0.99 if you find it on sale, and it penetrates EVERYTHING! It's the same as Gun Scrubber, but at 60% less cost.
Gun cleaning doesn't have to be difficult, or expensive. It only has to be THOROUGH.
WD-40 just doesn't cut it.