Rabbi Ami teaches that this law applies only to a child that was clearly born as a firstborn son. If the child was a tumtum, then he would not receive the double portion, even if we later found him to be a male child.
The Gemara describes a tumtum as someone whose gender cannot be determined. Sometimes this condition stems from an inherent genetic defect, and the child will remain in that state for his entire life. Other cases of a tumtum are caused by low levels of male or female hormones in the developing child. Under such circumstances, the sex organs may actually develop at a later time – sometimes years later. In such cases, if the male sex organ develops, it appears as if the physical covering that hid the sexual organ has been removed (in the language of the Gemara it is nikra, or “torn” off) and the individual can be identified as male.
A tumtum – even one whose gender is determined after a time – will not receive the double portion because the passage (Devarim 21:15) refers to ha-ben ha-bekhor – the son who is firstborn – which is understood to require the firstborn to be a son at the time of birth, and not someone whose gender was determined at a later date.
Although the tumtum would not be considered a firstborn male child for the purposes of receiving a double share, he will still receive a simple share as a male child. Ameimar teaches that even though he will receive a portion he would not be considered a male son when calculating the firstborn share. Thus, if there were four children in the family – a firstborn son, two ordinary children and the tumtum who was found to be male, we first calculate the estate as if there were four shares – the firstborn, who receives two shares and his two brothers who receive one share apiece. After we give the firstborn his extra quarter share, the three-quarters that are left will be divided into four shares – one for the firstborn, one each for the two ordinary brothers and one for the tumtum.