Sanchez What about the 10,000 people that live in Spain but cross the border to work in Gibraltar every day? Where would their tax residence be? As I understand it they are classed as being tax resident in Spain by Hacienda.
That situation (working on the other side of the border to where one lives) is specifically covered in the tax laws, so there are no problems.
Any real person (as opposed to hypothetical situations) who is in doubt, because their situation is not specifically covered, can approach the Hacienda and/or the tax authority in their country, and the two authorities will let you know what you must do.
Thus those who believe they can slip between the various laws and are misinformed, i.e. no one can just choose where / if they pay tax.