MATLAB: Empty default switch-case-structure if temporal logic is inside if-else triggered subsystem

codeEmbedded Codergenerationif elseswitch case

If temporal logic (e.g. 'after') is used in state charts that reside inside an if-else triggered subsystem, the generated code replaces the expected if-else structure by a switch-case-structure with an empty default case.
This does not happen when replacing the temporal logic by explicitly implemented timers using local variables. The impact in my project is that the used tasking compiler throws compiler warnings for the empty switch-case default path. However, I do not want to replace temporal logic with self-implemented timers for readability reasons and also I do want to use if-else triggered subsystems.
How can I solve this?

Best Answer

This is related to the setting for the 'CastingMode' parameter for the model.
When that parameter is set to 'Standards', the code generator does not optimize away the empty default case because not having a default case is a MISRA violation that we want to preserve. The development team is considering this as a potential enhancement request under consideration for a future release since this issue feels out of place and unrelated to Casting Modes.
As a workaround, you should be able to change the 'CastingMode' parameter to something other than 'Standards'. If you do intend to be MISRA compliant then you will want to keep the empty default case in the switch statement.