Skip to content

Fix multinewarray #686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 24, 2017
Merged

Fix multinewarray #686

merged 2 commits into from
Mar 24, 2017

Conversation

smowton
Copy link
Contributor

@smowton smowton commented Mar 23, 2017

Just realised my Java multinewarray fix had fallen by the wayside. Here it is again-- in current master multinewarray (multi-dimensional array alloc) always fails with "unexpected assignment to empty" (deref of a void pointer); this gets at least basic functionality working (i.e. test multinewarray passes). Fixes #192

smowton added 2 commits March 23, 2017 12:44
Simply assigning to a temporary symbol of the correct type and
amending the type passed to the elaboration of the sub-array seems
to suffice to properly initialise a multi-dimensional array.
for_loop.init()=code_assignt(tmp_i, from_integer(0, tmp_i.type()));
for_loop.cond()=binary_relation_exprt(tmp_i, ID_lt, rhs.op0());
for_loop.iter()=inc;
for_loop.body()=code_skipt();
for_loop.body()=code_assignt(deref_expr, sub_java_new);
for_loop.body()=for_body;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does the recursion happen that one would (seemingly) need for, e.g., a three-dimensional array?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The java-new-array expression created is one operand shorter, so if it's still 2 or longer we'll end up here again when we convert it

@kroening kroening merged commit 96c9e65 into diffblue:master Mar 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants