Deiphi編譯優化導致的死迴圈

2021-03-31 19:14:04 字數 876 閱讀 2738

請看下面這段**:

procedure tform1.button1click(sender: tobject);

varstrcolor: string;

i, r, g, b, p: integer;

strlist: tstringlist;

begin

strcolor := medt.text + '-';

strlist := tstringlist.create;

tryfor r := 0 to 2 do       //把變數r改為i正常

begin

//showmessage(inttostr(r));   加上這句也正常了 迴圈體內讀過r 值

p := pos('-', strcolor);

strlist.add(copy(strcolor, 0, p-1));

delete(strcolor, 1, p);

end;

r := strtoint(strlist[0]);

g := strtoint(strlist[1]);

b := strtoint(strlist[2]);

finally

strlist.free;

end;

self.color := tcolor (rgb (r, g, b));

edtcolor.text := '$' + inttohex (tcolor (rgb (r, g, b)), 8);

edtcolor.setfocus;

end;

因為迴圈語句中沒有沒有使用r變數,而在迴圈外有對r的使用。編譯器優化導致的錯誤? delphi中,在迴圈體內是不能更改迴圈因子的。

下面貼出反編譯的彙編**:

20140213 想念是while裡的死迴圈

stdafx.h 標準系統包含檔案的包含檔案,或是經常使用但不常更改的 特定於專案的包含檔案 pragma once include targetver.h include include include include define 我還記得 void define 在東校 main define...

hibernate4導致的Ajax請求死在那裡

不是hibernate的錯,那就是我使用不當,環境 我們搭建的springmvc4 hibernate4 使用hibernate4事務和session訪問資料庫 不是spring的jdbctemplate或hibernatetemplate 如此訪問資料庫和事務架構我無法理解,也懶得抗拒 如果你使用...

Bitcode導致的編譯報錯

在xcode7.1進行archive時,會報這樣的錯誤 ld object contains invalid bitcode users umsocial sdk extra frameworks wechat libwechatsdk.a wechatauthsdk.o for architect...