I'm not understanding the direction you are going with the question. A G19 is a 9mm and a G23 is a .40S&W.
As far as a Gen3 mag fitting a Gen4 gun or vice versa, a Gen4 mag will work in a Gen3 gun for a given model, but a Gen3 mag will only work in a Gen4 gun if the mag release is kept on the left side of the gun (not switched to the other side for southpaws).
Others will chime in shortly to further explain, but it would help to know where you are going with the question...