Can losing weight quickly cause gallstones?
Rapid weight loss is a recognised risk factor for gallstones, and the NIDDK treats it as well enough established to warn about directly. The mechanism involves changes in how the liver handles cholesterol and how often the gallbladder empties during a period of very reduced intake.
The risk is associated with the speed of loss rather than weight loss itself, which is why gradual loss is generally described as lower risk than very fast loss. Gallstones can also form during the weight-loss phase without causing symptoms at all.
If you are losing weight quickly, whether through diet, surgery or medication, this is worth raising with your clinician rather than treating as background noise, because the plan can often be adjusted. Sudden severe pain in the upper right abdomen is not something to research at home.