CO2 is the trigger that creates the urge to breathe and wanting to breathe and knowing you can't is the uncomfortable part.
Once you actually spasm and attempt to inhale, you are probably so low on O2 that you will not be aware for long before the lights go out.
Another thing to conisder is the interplay of partial pressure in this scenario. Free divers are prone to shallow water black out in situations where the partial pressure continues to drop on ascent to the point where they pass out before reaching the surface. This condition is aggravated by excessive hyperventilation before the dive where CO2 levels are reduced to the point that free divers feel able to stay at depth longer than is really prudent.
But the same thing would occur during ascent with higher CO2 levels. Once the partial pressure of oxygen falls to the point where O2 is no longer passing from the lungs into the blood stream, you only have a few seconds of conciousness left - maybe 15 seconds at the outside. So in essence if you are asceding the odds are good the lights will just go out before you reach the CO2 induced point of feeling the uncontrollable need to inhale.
If you are potentially in that situation, be sure you are positively bouyant as on the surface you will at least be visible and may have some chance of being rescued and revived if you have in fact reached the point where you will no longer spontaneously breathe on the surface. This is also a situation where breathing whatever you have is appropriate even if it is high O2 deco mix or the gas in your BC.
Knowing all that, if it were me and if I were in a hard overhead environment and knew beyond all shadow of any doubt that there was no possible way to reach the surface (inside a wreck, cave, etc) I'd probably consider using the last few hundred PSI to hyperventilate before holding my breathe, taking the reg out and waiting to peacefully lose conciousness. Which would of course confuse the accident analysis folks since there would still be air in the tank, a reg floating free, no signs of a struggle, etc. and they would probably misinterpret the situation as oxtox or something else equally incorrect.