I was reading this paper on undefined behaviour and one of the example \"optimisations\" looks highly dubious:
if (arg2 == 0) ereport(ERROR,
In embedded systems, functions that never return are commonplace. They should not be optimized either.
For example, a common algorithm is to have a forever loop in main() (a.k.a. the background loop), and all functionality takes place in an ISR (Interrupt Service Routine).
Another example are RTOS tasks. In our embedded system project, we have tasks that are in an infinte loop: Pend on message queue, process message, repeat. They will do this for the life of the project.
Some embedded systems have safe shutdown loops where they place the machine into a safe state, locking out all User Input, and wait for power shutdown or reset.
Also, some embedded systems can shutdown the system. Shutting down the power prevents the system from returning.
There are reasons that not all functions need to return or must be required to return. If all functions returned that are in your cell phone, you wouldn't be fast enough to use it.