Castor Semenya a case in point, although intersex in the other direction.It isn't 100%. You can be XY (genetically a normal male) and still be female looking (female gentials etc, but you will normally be sterile). Quite a few genetic issues that can cause gender screw ups..