Commit bd2405e2 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Fix crash when the model contains 1st or 2nd ext fcn deriv nodes.

In the case where the external function computes itself its derivatives, the
TEF terms were not always created before being used, hence leading to a
preprocessor crash. This problem could only happen with ramsey_policy, because
otherwise the model does not contain derivatives of external functions.
parent 8882f809
......@@ -5018,7 +5018,17 @@ FirstDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Exp
int first_deriv_symb_id = datatree.external_functions_table.getFirstDerivSymbID(symb_id);
assert(first_deriv_symb_id != eExtFunSetButNoNameProvided);
if (first_deriv_symb_id == symb_id || alreadyWrittenAsTefTerm(first_deriv_symb_id, tef_terms))
/* For a node with derivs provided by the user function, call the method
on the non-derived node */
if (first_deriv_symb_id == symb_id)
{
expr_t parent = datatree.AddExternalFunction(symb_id, arguments);
parent->writeExternalFunctionOutput(output, output_type, temporary_terms,
tef_terms);
return;
}
if (alreadyWrittenAsTefTerm(first_deriv_symb_id, tef_terms))
return;
if (IS_C(output_type))
......@@ -5285,8 +5295,17 @@ SecondDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Ex
int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id);
assert(second_deriv_symb_id != eExtFunSetButNoNameProvided);
if (alreadyWrittenAsTefTerm(second_deriv_symb_id, tef_terms)
|| second_deriv_symb_id == symb_id)
/* For a node with derivs provided by the user function, call the method
on the non-derived node */
if (second_deriv_symb_id == symb_id)
{
expr_t parent = datatree.AddExternalFunction(symb_id, arguments);
parent->writeExternalFunctionOutput(output, output_type, temporary_terms,
tef_terms);
return;
}
if (alreadyWrittenAsTefTerm(second_deriv_symb_id, tef_terms))
return;
if (IS_C(output_type))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment