MATLAB: Do I receive a segmentation violation or assertion when I use MAX on a casted tunable parameter in Simulink 4.1 (R12.1)

bridge.dllmnsignalhandlersimulinkstrvectormerge

I performed the following steps:
1. Created a parameter "K" in the MATLAB workspace.
2. Created a new Simulink model with a Constant block going to a Display block
3. Set the parameter "K" to tunable with an "ExportedGlobal" storage class using the Optimization pane in the Configuration Parameters dialog.
4. Set the "Constant value" in the constant block to:
max(single(K))
5. Ran the model
I then received the following segmentation violation:
------------------------------------------------------------------------
Segmentation violation detected at Fri Feb 18 09:41:43 2005
------------------------------------------------------------------------
Configuration:
MATLAB Version: 7.0.1.24704 (R14) Service Pack 1
MATLAB License: DEMO
Operating System: Microsoft Windows XP
Window System: Version 5.1 (Build 2600: Service Pack 2)
Processor ID: x86 Family 6 Model 9 Stepping 5, GenuineIntel
Virtual Machine: Java 1.4.2_04 with Sun Microsystems Inc. Java HotSpot(TM) Client VM
(mixed mode)
Default Charset: ibm-5348_P100-1997
Register State:
EAX = 0012b2b8 EBX = ffffffff
ECX = 107057d0 EDX = 0012b2b9
ESI = 10705c50 EDI = 0012b2b8
EBP = 00cdaae0 ESP = 00cdaadc
EIP = 7870e940 FLG = 00210206
Stack Trace:
[0] libut.dll:_utStrdup(1225400, 0, 0, 0) + 16 bytes
[1] simulink.dll:struct slErrMsg_tag * __cdecl StrVectorMerge(struct StrVector *,struct StrVector *)(0x107057d0, 0x101b3fc0 "max(single(table1(:,1) ))", 0x100c7130, 0x101b58e0) + 48 bytes
[2] simulink.dll:struct slErrMsg_tag * __cdecl WarnForLossOfTunabilityRootAST(struct AST_tag *,struct ExprTunVarsInfoList *,struct slBlock_tag const *,char const *,char const *)(0x101b58e0, 0x106fa930, 0x100c7130, 0x7a3a8274 "Value") + 114 bytes
<snip>

Best Answer

This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
We have verified that there is a bug in Simulink 4.1 (R12.1) when using non-double math with tunable parameters.
To work around this issue, type cast the parameter to a non-double value after performing the math operations when possible. For example, change the Constant value from:
max(single(K))
to
single(max(K))