Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
3068fbda
Commit
3068fbda
authored
Sep 23, 2010
by
Sébastien Villemot
Browse files
Preprocessor: no longer crashes when some dynamic variables appear only in
unused model local variables (closes #101)
parent
45ebd1b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
preprocessor/ModelTree.cc
View file @
3068fbda
...
...
@@ -1143,11 +1143,18 @@ ModelTree::compileTemporaryTerms(ostream &code_file, unsigned int &instruction_n
void
ModelTree
::
writeModelLocalVariables
(
ostream
&
output
,
ExprNodeOutputType
output_type
)
const
{
for
(
map
<
int
,
expr_t
>::
const_iterator
it
=
local_variables_table
.
begin
();
it
!=
local_variables_table
.
end
();
it
++
)
/* Collect all model local variables appearing in equations, and print only
them. Printing unused model local variables can lead to a crash (see
ticket #101). */
set
<
int
>
used_local_vars
;
for
(
size_t
i
=
0
;
i
<
equations
.
size
();
i
++
)
equations
[
i
]
->
collectModelLocalVariables
(
used_local_vars
);
for
(
set
<
int
>::
const_iterator
it
=
used_local_vars
.
begin
();
it
!=
used_local_vars
.
end
();
++
it
)
{
int
id
=
i
t
->
firs
t
;
expr_t
value
=
it
->
second
;
int
id
=
*
it
;
expr_t
value
=
local_variables_table
.
find
(
id
)
->
second
;
if
(
IS_C
(
output_type
))
output
<<
"double "
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment