I have also occasionally been able to reproduce this by jumping into deep water from a dock or similar location, but it only happens 100% reliably when disembarking from boats.
For the bug to occur, the weapons in question need to be equipped. If you switch to sidearm before attempting, it doesn't happen and you are able to swim just fine.
Entering the water from shore works fine as well, regardless of what gun is equipped.
I suspect this might be the case with other guns as well, but I have only noticed, reproduced and tested it with the above mentioned guns.