I used to frequent a firearms related forum and someone asked if anyone had accidentally travelled with a firearm and there were plenty of stories.
Lots of examples of traveling with ammunition either loose or in magazines and it not being caught on airport x-ray. But also stories of people grabbing something from a carry-on and realizing they forgot their loaded handgun was in there.
Normally it's not that big a deal if you're flying within the US (though NY and NJ can be dicey), but I also recall a story where someone flew international and the destination was a country that would put you in prison for a long time even if you came forward (I think it was Japan or China).
They were asking advice on what to do and I think in the end they unloaded it, took the gun apart (barrel, slide, frame, etc) and dumped each part in a separate trash bin far, far apart.