Is it safe to instantaneously discharge 100nF 5V through an HC CMOS gate?
This is a SAFE_OPERATING_AREA (pulse) question. The thermal timeconstant of silicon, at 1millimeter thickness, is 11.4 milliSeconds. If the heating event is at or shorter than 11.4milliSeconds, the heat remains within the die, not even having reached the metal flag/paddle under the die.

How fast does the 0.1UF discharge? The Requiv is 5v/50mA ==100 ohms. The RC timeconstant is 100 ohm * 0.1uF, or 10 microSeconds. In that time, the heat mostly remains within the top 30 microns of the silicon, and is at least 70 microns away from the flag/paddle. [10u cube tau 1.14uS, 100u cube tau 114 uS]

Lets use a volume of 30*30*30 microns, or roughtly 30,000 cubic microns.
Using 1.6 picoJoule/micron^3 * Deg C, scaled by 30,000 we find the specific heat of our cube: 50,000 picoJoule, or 50 nanoJoule/30micron^3 * degC.

The energy stored in the cap is 1/2 * C *V^2 = 1.25 microJoules. Divide this by 50 nanoJoule, and we get 25 degree C rise, during that 10uS discharge.

For this answer, with all the heat trapped inside the silicon, the heat has not had time to even reach the bottom flag/paddle.