In reply to tom_in_edinburgh:
My experience is that it doesn't unless its within c.1-2". I tried various common objects that can affect a compass and even items with v.strong magnets (e.g. VHF Radio mic) didn't affect it until it was in close proximity (about 1-2 inches).
The flip side was that a lot of things (such as loose AA batteries) that you might not think about did affect it, as did camera's etc. not flipping, but certainly deflecting the needle.
I know of 3 occurrences of flipping compasses and of those 2 were caused (most likely) by the compass being stored in contact with a mobile phone. It's that kind of direct contact that seems to be the killer for them. No supprise really if we think back to school physics and polarising bits of steel by stroking them with strong magnets etc.
I also once bought a compass (about 10 years ago) which was pre-flipped! Took it back to the shop and they changed it without question and said that they'd a quite a few back from the same batch, something had knackered the polarity of them in transit from the maker to the shop. So its not a new problem.
Reverse polarity is in the public eye at the minute, but it's also important to remember that stored properly a compass is still an ultra reliable piece of kit that can and should be trusted.