From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cebf,cef967896fcfc1f4,start X-Google-Attributes: gid10cebf,public X-Google-Thread: 1164f8,cef967896fcfc1f4,start X-Google-Attributes: gid1164f8,public From: "Gilles Vollant" Subject: Big compiler bug with VC++5.0 SP2 on alpha Date: 1997/10/11 Message-ID: #1/1 X-Deja-AN: 279595284 X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3 Newsgroups: comp.sys.dec,comp.sys.dec.micro Just save the sample included. Compile with cl /Zp1 /Od bug.cpp and it will not perform as needed ! /* ------------------------------------------------------------------------- */ //Save this file under name bug.cpp, compile vith Visual C++ 5.0 SP2 DecAlpha // "cl /Zp1 bug.cpp" -> BAD RESULT // "cl /Zp1 /Od bug.cpp" (or any other platform) -> GOOD RESULT /* ------------------------------------------------------------------------- */ #include #include #include #include class MINICLASS { protected : LPVOID lpv; private : // If we remove the "WORD toto", there is no bug WORD toto; protected : DWORD hWndMap; LONG ListID; public : MINICLASS(){ }; virtual ~MINICLASS(){ }; DWORD GetWndMap() { return hWndMap; }; BOOL SetMap(DWORD hWndMap); LONG GetListID() { return ListID; }; void SetListID(LONG lListID); }; DWORD GetBrowserMapWindow(MINICLASS* lpAux) { DWORD hWndResult=NULL; if (lpAux) { if (lpAux->GetListID()<0) hWndResult=49; else hWndResult=lpAux->GetWndMap(); }; return hWndResult; }; void MINICLASS::SetListID(LONG lListID) { ListID=lListID; } BOOL MINICLASS::SetMap(DWORD SethWndMap) { hWndMap = SethWndMap ; return TRUE; } void main() { MINICLASS br; br.SetListID(-3); // lpAux->GetListID() will return -3 br.SetMap((DWORD)-4); // lpAux->GetWndMap() will return -4 DWORD dwRes=GetBrowserMapWindow(&br); if (dwRes==49) printf("GOOD RESULT - resultat correct\n"); else printf("BAD RESULT - compiler bug - resultat mauvais\n"); }