You can have the trap during production, and then it is safer. If you need to catch the problem at run-time, there are checked integer options in C that you can use.