How does pdflatex avoid the problem. I don't know what it uses to decide on A4 vs. Letter size, but one way or the other, it has to make the decision.