Note 24:

History of exceptions

The first vowel in ganhar © is an open vowel, although it is in an unstressed syllable and before nh. Both are normally enough reason for a /3/ sound (as if written รข, but unaccented), but not in this particular word. Perhaps the background of this strange un-Portuguese behaviour is in the French origin, from gagner ? Old-French itself has it from a Germanic language. Cf. English gain from Old-French gaaignier).

This is an exception that is probably very old. For the related but less convincing word "ganho" it is already attested in De Lima 1736, on page 6.