MATLAB: Is a SimulinkGlobal Simulink.Parameter in Model Workspace gets optimized compared to when declared in Base workspace when using Embedded Coder 8.2 (R2012a)

Embedded Coder

I'm trying to embed a SimulinkGlobal Simulink.Parameter in the simulink model file. My model uses a constant "p1". If I define a Simulink.Parameter 'p1' in the MATLAB/Base workspace with CoderInfo.StorageClass of SimulinkGlobal, the behavior is what I expect: a parameter "p1" gets created in the generated code. But if I do the same thing in the Model Workspace, 'p1' gets optimized out and the generated code just uses an inline constant, which is not what I want.
Why is the Simulink.Parameter storage class seems to be ignored?
When the Simulink.Parameter is defined in the Model Workspace:
testingSimulinkParameter_Y.Out1 = testingSimulinkParameter_ConstB.Gain;
where:
const ConstBlockIO_testingSimulinkPar testingSimulinkParameter_ConstB = {
22 6.0
23 /* '<Root>/Gain' */
24 };
When the Simulink.Parameter is defined in the Base Workspace:
testingSimulinkParameter_Y.Out1 = testingSimulinkParameter_P.p1 * 2.0;
Parameters_testingSimulinkParam testingSimulinkParameter_P = {
22 3.0 /* Variable: p1
23 * Referenced by: '<Root>/Gain'
24 */
25 };
Why is the named variable p1 lost when defined in Model Workspace? I should be able to preserve the variable name 'p1' when defining the simulink.parameter as simulinkGlobal in model workspace also. Is this a bug.

Best Answer

This is not a bug. The following warning appears when you generate code with the parameter object in the model workspace:
Warning: The storage class for parameter 'p1' (in workspace 'testingSimulinkParameter') is ignored because only 'Auto' storage class
is permitted for parameters in the model workspace. Either correct the storage class or move the parameter to the base workspace.