I don't know if anyone else noticed, but the problem doesn't lie in the mouse collision detection or event handling at all. If you look very carefully at the video(s), you will notice the position of the sf::RectangleShape changes between executions. Maybe this is a sign that I've been working on GUIs for too long
.
You can throw out the collision detection code and all the event handling, and it might probably still occur that the sf::RectangleShape doesn't stay in the same position although the hardcoded position doesn't change, and that is the real problem, not the fact that the collision is not properly detected. The collision detection uses data that is saved in the user code, not the data representation inside SFML. If you were to query the sf::RectangleShape for its position in one of those broken executions, it would probably return some bogus values.
The only critical places I would look at are:
sf::Vector2f position;
...
position = {100,100};
...
rect.setPosition(position);
When initially constructing the sf::Vector2f, its constructor sets both x and y values to 0, regardless of data type, no narrowing conversion should ever be required.
The second one is a bit trickier. Normally you would be able to initialize data structures using aggregate initialization with the { 1, 2, 3 }; syntax, but only if the object doesn't have any user defined constructors, which sf::Vector<T> has. So in C++03 that syntax would be illegal. It only works because -std=c++11 is used. In C++11 it isn't about aggregate initialization any more. That expression evaluates to a construction of a new sf::Vector2f to assign to position due to uniform initialization. In this case as well, a non-narrowing conversion has to be performed.
The last spot is when the position is finally passed on to SFML. Since SFML takes the parameter by reference, I don't see much opportunity for anything to go wrong there.
Obviously, something is going wrong somewhere. The executable produced by the compiler/linker should stay the same unless your disk was dying in the process of your testing. The only spot I could think of where something might go wrong is during the conversion from int to float. Normally it should not be a problem since it is not a narrowing conversion, but considering something has to be a problem, that would be the most likely candidate, short of random memory corruption due to broken RAM, a broken disk, a broken processor, or (since it only happens on Arch) a broken runtime environment and/or kernel.
I would try to minimize the opportunities for the culprit to mess with your data and try to avoid unnecessary conversions, as is the case in all your code examples. Also, try to print out the data before it gets passed over to SFML, even though it should be what you would expect, better safe than sorry. Over time developers learn to trust their compiler and runtime environments, but a little scepticism can go a long way sometimes, especially when something has to obviously be broken.