Proper care of firearms requires regular cleaning after a round of shooting and proper coating of metal surfaces when the gun is to be stored for any length of time. It also requires lubricating the moving parts to ensure safe operation. The choice of chemicals to use for cleaning, lubricating and preventing rust or corrosion fall into two main categories: silicone-based products and petroleum-based products. Both gun oil and WD-40 are petroleum products, so which is better to use to care for your firearms?
The chemical constituents of WD-40 are a closely held trade secret. The manufacturer does, however, state that its product contains no silicone. It also does not contain kerosene, water, wax, graphite or chlorofluorocarbons. It does serve to displace water--the "WD" stands for water displacement--and a penetrant. This latter component may render it less than perfect for use on firearms.
Gun oils, on the other hand, may also contain chemicals that the manufacturers state are purposefully included for specific use on firearms. Gun owners typically have their favorite products, so the discussions and arguments tend to be less empirical than conjectural.
Most gun owners agree that it is better to go easy on the amount of product used when cleaning their guns. It is especially important to keep excessive oil out of the bore and action of any firearm. WD-40 claims to get under dirt, grime and grease to clean metal surfaces, and most dedicated gun oils have a similar ingredient to do the same. Either product is a better choice than solvents, which can leave an oily film on the surface when they dry.
Precious little oil is required to lubricate the actionable parts of a firearm. Excess oil collects dust and dirt and can serve to accelerate wear. Excess lubricant can also gum up an action. WD-40 has fewer lubricating properties than dedicated gun oils.
WD-40 will make moisture bead up and run off metal. The bluing on a firearm protects the metal from the effects of moisture when the firearm is being used in the rain, but it can't hurt to spray some WD-40 on a cloth and wipe it over the external metal surfaces of the gun before venturing out in a storm. If a gun has been accidentally submerged, WD-40 makes a great stopgap measure to flush water from the internals before it can be disassembled and properly re-oiled. Many gun owners will not leave a film of WD-40 on a gun for storage purposes, claiming it can promote mildew and that the gun can become gummy.
WD-40 contains a "penetrant," so it may not be a good idea to use it on a good wooden stock in which it could attack and soften the underlying wood. Regular gun oils also shouldn't be used on the stock. Regular gun oil is a completely different formula from that used to finish stocks.