More lessons - Arianne 5
I'm still going to bet the problem isn't a simple coding error.
People are assuming that the GCU was coded from scratch. It probably wasn't. The real time control executive was quite possibly an off the shelf, ready flight qualified and certified system. A great thing to use. But again - who was responsible for the requirements - and especially understanding that the aircraft systems might need to stay powered up for nearly a year?
In a real time control system you have a constraint of CPU cycles. You don't burn them without reason. It may be perfectly reasonably, and well reasoned that the timer will be coded with no wrap. What do you do if it does wrap? It is difficult, to say the least, to cope with time that goes backwards. So as Hugo Tyson notes above - you have more, not less, problems.
In a hard real time control system you can't simply throw an exception. Who catches it, and what does it mean? Indeed - everyone is assuming that the clock wrap wasn't caught - it could easily have been caught and it was the catching of the clock wrapping that caused the shutdown.
This is where it gets messy. And brings us to the first ever flight of Arianne 5. The flight control software was derived from the Arianne 4, and was a known solid bit of code. But it needed modification to cope with the changes in design. A piece of effectively dead (unneeded) code, that was otherwise benign, was driven into an unusual state by higher than expected winds, and threw an exception. Nobody caught it. Exit $400m worth of rocket in a very spectacular failure. The failure was in a perfectly good piece of code that the changed requirements didn't pick up needed addressing and testing - because it was not needed for the new vehicle.
Writing error free code is easy. It is getting the precise requirements and integration of that code that is really hard. The idea that not picking up the clock could wrap is the error isn't the hard part. It is very unlikely that the clock wrapping wasn't known. It is very likely that a clear understanding of the environment the code would see itself in was not fully addressed along the chain of requirements analysis from the early design briefs of the plane, all the way down to the contractor responsible for coding it. This chain can fail in many many ways, and is a vastly harder thing to manage and get right than simply coding a counter, or indeed even a quite complex bit of software.