The Gemoro on 89a discusses Moshe Rabbeinu going up Har Sinai for 40 days. Rashi and Tosfos argue about the Cheshbon of 40 days and what the mistake of the people was, but I am not clear on their exact reasoning. I also saw the Maharsha and the Chochmas Shlomo who make further points. (From the Gemoro in Yoma (4), it seems that Moshe went up Har Sinai on 7th Sivan irrespective of whether Matan Torah was on 6th or 7th. Of course, we can always play with months being possibly 29 or 30 days to suit).
Are you able to supply a full discussion of the opinions of Rashi, Tosfos & others?
Meir Eliezer Bergman
According to Rashi, Moshe was referring to forty regular days beginning from the following night. Indeed, he ascended Har Sinai on the seventh of Sivan, and he descended on the morning of the middle of the fortieth day,beginning from the night of the eighth (which coincided with the seventeenth of Tamuz). Yisrael erred in that they counted the first day as part of the forty days, thinking that the days consisted of twenty-four hours starting from the day. According to the people's reckoning, Moshe ought to have arrived on the morning of the beginning of the fortieth day. In fact, he arrived in the middle, according to his reckoning.
Accordng to Tosfos, the forty days did indeed begin with the day that he ascended Har Sinai. Only he descended the morning after the forty days terminated, whereas the people thought that he would arrive on the morning of the beginning of the fortieth day.
You say you saw the Maharshal, who answers Tosfos second Kashya on Rashi concerning the last forty days terminating after Yom Kipur, but who agrees with their third Kashya, that if, as Rashi learns, Moshe ascended Har Sinai for the second time on the nineteenth of Tamuz (rather than on the eighteenth), then it is irreconcilable. Which Maharsha were you referring to?
Finally, your understanding of the Sugya in Yoma, that Moshe ascended Har Sinai on the seventh of Sivan, irrespective of .... , is certainly correct. The Gemara generally assumes that the months of the year follow the strict pattern of Malei (Nisan), Chaser (Iyar), Malei (Sivan), Chaser (Tamuz), unless one needs to say otherwise. This is clear from the Sugya there 87b - 88a, and from the Sugya in Ta'anis (29a), which explains that they declared Tamuz of the second year Malei so that the Meraglim should return just before the night of Tish'ah be'Av.
be'Virchas Kol Tuv