Why do FPU/SSE exceptions occur at runtime in the generated TwinCAT module, but not in the Simulink model?

In the default settings, Simulink may treat floating point exceptions differently than TwinCAT 3.

In order to adjust the behavior for floating point exceptions between Simulink and TwinCAT, in the Signals box under Model Configuration Parameters in Simulink in section Diagnostics >Data Validity you can choose between:

To debug an SSE exception in TwinCAT, please use the C++ debugger, see Debug in the TE1400 documentation. Provided you have built your model as a "debug" module with the C++ debugger activated, it is sufficient to attach to the process after TwinCAT has started, if the exception occurs during the initial cycles. In many cases the SSE exception occurs directly in the first cycle. In this case, a division by zero can occur quickly if certain signals are initialized with zero.
Another way to encounter SSE exceptions is to disable floating point exceptions. These can be deactivated in the System Manager under Tasks (uncheck the floating point exceptions checkbox). This setting then applies to all modules that are addressed by this task. If an exception occurs, a NaN is generated and no error is output.

Notice

Deactivating floating point exceptions

NaN values may only be used in other PLC libraries, in particular as control values in functions for Motion Control and for drive control, if they are expressly approved! Otherwise, NaN values can lead to potentially dangerous malfunctions!