Well we can't, since we don't have code access, but the industry has created specialized programs that test and verify code design to validate that there are no loose corner cases. Then the routines are wrapped in check calculations with shadow ECC memory and run on specially designed safety processors with dual cores in lock step.
Hercules (processors) - Wikipedia
Airliners are fully fly by wire, that's the level of fault elimination that has been achieved.
If you are interested, the transcript from the Toyota UA case had lots of coverage of the technical aspects and where their SW failed to maintain redundancy, thus allowing for the possibility that the UA was SW induced.