To actually interrupt the functioning of the gun,,I can't think of any common magnet that would do that.
Maybe a real powerful one in an Arnold movie.
The point already made about creating a magnetic field around the gun parts and then the part(s) annoyingly pick up every tiny flake of ferris metal around,,yes it can.
I've have that happen to hand tools and parts in the shop.
But the place is always covered with a layer of filings and other metal 'dust' from finishing.
Unless you're in that environment,,I doubt you'd find much of a problem.
Another thought,,and I don't have an answer,,
Could some of the modern optics be effected in anyway. I'm not in to 'scopes, but some of the latest seem to be so much more than a tube and lenses. Maybe they already took that problem into consideration in the design.