You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an array is resized in a loop that contains a control flow statement, such as a break statement, the shape of the array is sometimes incorrect.
For example, I have the following MATLAB function:
functiony=test
t1 =1;
t2 =20;
t3 =10;
for i =t1:t2
y(i) =t1;
ifi>t3break;
endendend
The array y is resized inside the loop, which iterates from 1 to 20, but breaks after 10, so it really iterates from 1 to 11.
And this is what I get when I print the callgraph:
% args: {}
function [y] = test()
t1 = 1; % t1=(t1,double,1.0,[1, 1],<1, 1>,REAL)
t2 = 20; % t2=(t2,double,20.0,[1, 1],<20, 20>,REAL)
t3 = 10; % t3=(t3,double,10.0,[1, 1],<10, 10>,REAL)
for i = (t1 : t2);
y(i) = t1; % y=(t1,double,[1, 20],REAL)
[mc_t0] = gt(i, t3); % mc_t0=(logical,[1, 1],REAL)
if mc_t0
break;
else
end
end
end
% results: [(t1,double,[1, 20],REAL)]
The size of y is marked as [1,20], which is incorrect. It should ideally be [1,11], but [1,?] is probably more realistic.
When an array is resized in a loop that contains a control flow statement, such as a break statement, the shape of the array is sometimes incorrect.
For example, I have the following MATLAB function:
The array
y
is resized inside the loop, which iterates from 1 to 20, but breaks after 10, so it really iterates from 1 to 11.And this is what I get when I print the callgraph:
The size of
y
is marked as[1,20]
, which is incorrect. It should ideally be[1,11]
, but[1,?]
is probably more realistic.(Here's the Java code I used)
The text was updated successfully, but these errors were encountered: