« SomeTools for Visual Studio .NET | 回到主頁面 | The scope bug of "for loop" »

March 29, 2005

Interesting bug in VC6


將此網頁加入【百度收藏】... 加入此網頁到【del.icio.us 書籤】 technorati

Route 64 - Kang Su Gatlin talks about 64-bit最近在做VC6轉換VC7的時候,倒是慢慢發現VC6的一些bug,舉例來說,看一下下面的範例程式:

 if (int i)
 {
    i = 1;
 }

在VC6只會得到一個warnning:

warning C4700: local variable 'i' used without having been initialized

但是由於Constructor 通常不會有回傳值(return value),所以基本上在if() 不應該有變數的起始。所以這樣的code在GNU C++會發現是無法compiler過的~~~

當然VC7 修掉了這個嚴重的bug,你可以看到出現:

error C2059: syntax error : ')'

蠻有趣的bug,不過~~~ 若有人這樣寫code 可就慘了,因為雖然constructor沒有回傳值(return value),但是在VC6中, if (int i)卻是判斷為true~~~ 這樣~~可能是與原來的想法會有點出入~~~

所以有時候利用VC7來compiler一下現在的code,也是一個好主意。



VC6相關問題

由 Evan 發表於 March 29, 2005 將此網頁加入【百度收藏】... 加入此網頁到【del.icio.us 書籤】 technorati
引用
本文的引用網址:


以下是前來引用的連結 'Interesting bug in VC6' 來自 Blog E
迴響
發表迴響









記住我的資訊?




(請輸入以下的驗證碼)