Why does MLint issue an inappropriate 'might be growing inside a loop' warning?

The MLint shows a 'might be growing inside a loop' warning when a finite string is concatenated with each line of a file when a loop is used to access the file line by line.
For example, if you type in the following
function lint_2007jul18(fIn, fOut)
while true
tline = fgets(fIn);
if tline == -1, break; end
if ~isempty(strfind(tline,'skip'))
tline = [ '%<skip> ' tline ];
end
fwrite(fOut,'%s', tline);
end
end
MLint shows a warning 'might be growing inside a loop'.

 採用された回答

MathWorks Support Team
MathWorks Support Team 2009 年 6 月 27 日

0 投票

This is a known issue. Mlint runs a test to see if the variable is growing but its result is not guaranteed, which is why the warning says 'might be growing', not 'is growing'.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeOperators and Elementary Operations についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by