64ããããšã©ãŒã¯ãæéç匟ã«äŒŒãŠãããããæ€åºããã®ãååã«å°é£ã§ããããã«æããããªãå ŽåããããŸãã PVS-Studioéçã¢ãã©ã€ã¶ãŒã䜿çšãããšããã®ãããªãšã©ãŒãç°¡åã«èŠã€ããŠä¿®æ£ã§ããŸãã ãã ãããã®æ¹åã§ããã€ãã®æé ãå®è¡ãããŸãããæè¿ã64ããã蚺æãããæ éã«æ¹èšããããã®çµæãéèŠåºŠã¬ãã«ã«ããååžãå€æŽãããŸããã ãã®èšäºã§ã¯ããããã®å€æŽãšããããããŒã«ã®åäœãšãšã©ãŒã®æ€çŽ¢ã«ã©ã®ããã«åœ±é¿ãããã«ã€ããŠèª¬æããŸãã å®éã®ã¢ããªã±ãŒã·ã§ã³ããã®64ããããšã©ãŒã®äŸãå«ãŸããŠããŸãã
ã«ã€ããŠã®èšäºã¯äœã§ããïŒ
ãŸããã³ã³ãã³ãã®è©³çŽ°ã玹ä»ããããšæããŸãã ãã®èšäºã§ã¯ã次ã®ãããã¯ã«ã€ããŠèª¬æããŸãã
- 64ããããšã©ãŒã®æ€çŽ¢ã«åœ±é¿ããPVS-Studioã¢ãã©ã€ã¶ãŒã®å€æŽã
- PVS-Studioã¢ãã©ã€ã¶ãŒã«ãã£ãŠæ€åºããã64ãããã®ç¬¬1ã¬ãã«ãšã©ãŒã®ã¬ãã¥ãŒãããã³ãããã«é¢ããç°¡åãªã³ã¡ã³ãã
- PVS-StudioãšMicrosoft Visual Studio 2013ã䜿çšããŠæãéèŠãªãšã©ãŒãèŠã€ããéã®æå¹æ§ã®æ¯èŒã
æåã®æ®µèœã¯ããèªèº«ãç©èªã£ãŠããŸãïŒ64ããããšã©ãŒã®åæã«é¢ããPVS-Studioã®äž»ãªå€æŽãšãããããããŒã«ã®åäœã«ã©ã®ããã«åœ±é¿ããããèæ ®ããŸãã
2çªç®ã®ã¡ã€ã³ã»ã¯ã·ã§ã³ã¯ãå®éã®ãããžã§ã¯ãã§èŠã€ãã£ã64ããããšã©ãŒã«å°å¿µããŸãã ãããžã§ã¯ãã®ã³ãŒãã¹ããããã«å ããŠãã³ã¡ã³ããæäŸããããããèªåã§äœãæ°ããããšãåŠã¶ããšãã§ããŸãã
3çªç®ã®ã»ã¯ã·ã§ã³ã§ã¯ããããã®ãšã©ãŒã®æ€çŽ¢ã®æå¹æ§ãPVS-Studioéçã¢ãã©ã€ã¶ãŒããã³Microsoft Visual Studio 2013ç°å¢ã®ããŒã«ãšæ¯èŒããŸããããã«ãVisual Studioã®å Žåãã³ã³ãã€ã©ãŒãšéçã¢ãã©ã€ã¶ãŒã®äž¡æ¹ã䜿çšããŠãšã©ãŒãæ€çŽ¢ããŸããã
ããã€ãã®ãšã©ãŒã®ã¿ãããã«æžãåºãããããšãå¿ããªãã§ãã ããã å®éã®ãããžã§ã¯ãã§ã¯ããããã¯ç¢ºå®ã«ã¯ããã«å€§ãããããå€æ§ã«ãªããŸãã èšäºã®æåŸã«ã64ããããšã©ãŒã®äžçãããå®å šã«çŽ¹ä»ãããªã³ã¯ãæäŸãããŠããŸãã
64ããããšã©ãŒã«é¢é£ããPVS-Studioã®å€æŽ
å°ãåãŸã§ã¯ã64ããã蚺æã泚ææ·±ã調ã¹ãéèŠåºŠã¬ãã«ã«å¿ããŠããæ£ç¢ºã«é åžããŸããã
64ããããšã©ãŒã®ååžã¯æ¬¡ã®ããã«ãªããŸãã
ã¬ãã«1ãã¢ããªã±ãŒã·ã§ã³ã«æ害ãäžããé倧ãªãšã©ãŒã äŸãšããŠã32ãããã®intå€æ°ã«ãã€ã³ã¿ãŒãæ ŒçŽããŸãã 64ãããã¢ããªã±ãŒã·ã§ã³ãéçºããŠããå Žåã¯ãå¿ ãæåã®ã¬ãã«ã®èŠåã調ã¹ãŠä¿®æ£ããå¿ èŠããããŸãã
ã¬ãã«2ãéåžžã倧éã®ããŒã¿ãåŠçããã¢ããªã±ãŒã·ã§ã³ã§ã®ã¿çŸãããšã©ãŒã äŸã¯ã巚倧ãªé åã«ã€ã³ããã¯ã¹ãä»ããããã®ãintãåå€æ°ã®äœ¿çšã§ãã
ã¬ãã«3ããã®ä»ãã¹ãŠã ååãšããŠããããã®èŠåã¯é¢ä¿ãããŸããã ãã ããã¢ããªã±ãŒã·ã§ã³ã«ãã£ãŠã¯ãç¹å®ã®èšºæãéåžžã«åœ¹ç«ã€å ŽåããããŸãã
ãããã£ãŠã第1ã¬ãã«ã®64ããããšã©ãŒã§ãã£ã«ã¿ãªã³ã°ãããšããšã©ãŒã®å¯èœæ§ãé«ãã³ãŒãã»ã¯ã·ã§ã³ã瀺ãã¡ãã»ãŒãžã®ãªã¹ãã衚瀺ãããŸãã ãããã®èŠåãéå°è©äŸ¡ããªãã§ãã ããã64ããããšã©ãŒã®çµæã¯å€§ããç°ãªãå¯èœæ§ããããŸãããæããã«äžå¿«ã§ããããã°ãã°äºæããªããã®ã§ãã ç§ãã¡ã話ãã®ã¯åœŒãã«ã€ããŠã§ãã
PVS-Studioãªã©ã®ããŒã«ãªãã§ãã®ãããªãšã©ãŒãæ€åºããããšã¯ã©ãã»ã©é£ããã§ããããããã®èšäºãèªããšç解ã§ãããšæããŸãã
64ããããšã©ãŒåæ
ããŒã¿åãæ£ãã䜿çšãããããã«æ³šæããå¿ èŠããããŸãã ãããããããããå§ããŸãã
LRESULT CSaveDlg::OnGraphNotify(WPARAM wParam, LPARAM lParam) { LONG evCode, evParam1, evParam2; while (pME && SUCCEEDED(pME->GetEvent(&evCode, (LONG_PTR*)&evParam1, (LONG_PTR*)&evParam2, 0))) { .... } return 0; }
ã¢ãã©ã€ã¶ãŒã®èŠåïŒ
- V114å±éºãªæ瀺çãªåãã€ã³ã¿ãŒå€æïŒïŒLONG_PTR *ïŒïŒevParam1 test.cpp 8
- V114å±éºãªæ瀺çãªã¿ã€ããã€ã³ã¿ãŒå€æïŒïŒLONG_PTR *ïŒïŒevParam2 test.cpp 8
ãšã©ãŒã®æ¬è³ªãç解ããã«ã¯ãå€æ°ãevParam1ãããevParam2ãã®ã¿ã€ããããã³ãGetEventãã¡ãœããã®å®£èšã調ã¹ãå¿ èŠããããŸãã
virtual HRESULT STDMETHODCALLTYPE GetEvent( /* [out] */ __RPC__out long *lEventCode, /* [out] */ __RPC__out LONG_PTR *lParam1, /* [out] */ __RPC__out LONG_PTR *lParam2, /* [in] */ long msTimeout) = 0;
ã¢ãã©ã€ã¶ãŒã¡ãã»ãŒãžãããããããã«ãå±éºãªæ瀺çãªåå€æãå®è¡ãããŸãã å®éã«ã¯ãã¿ã€ã 'LONG_PTR'㯠' memsizeã¿ã€ã 'ã§ãããWin32ïŒ ILP32ããŒã¿ã¢ãã« ïŒ ã§ã¯ 32ããããWin64ã¢ãŒããã¯ãã£ïŒ LLP64ããŒã¿ã¢ãã« ïŒ ã§ã¯ 64ãããã®ãµã€ãºãæã¡ãŸãã åæã«ããLONGãã¿ã€ãã¯äž¡æ¹ã®ã¢ãŒããã¯ãã£ã§32ãããã§ãã åè¿°ã®åã¯64ãããã¢ãŒããã¯ãã£äžã§ãµã€ãºãç°ãªãããããããã®ãã€ã³ã¿ãŒã«ãã£ãŠåç §ããããªããžã§ã¯ãã®èª€ã£ãæäœãå¯èœã§ãã
å±éºãªåå€æã®ãããã¯ãç¶ããŸãã 次ã®ã³ãŒããèŠãŠãã ããã
BOOL WINAPI TrackPopupMenu( _In_ HMENU hMenu, _In_ UINT uFlags, _In_ int x, _In_ int y, _In_ int nReserved, _In_ HWND hWnd, _In_opt_ const RECT *prcRect ); struct JABBER_LIST_ITEM { .... }; INT_PTR CJabberDlgGcJoin::DlgProc(....) { .... int res = TrackPopupMenu( hMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, m_hwnd, NULL); .... if (res) { JABBER_LIST_ITEM *item = (JABBER_LIST_ITEM *)res; .... } .... }
ã¢ãã©ã€ã¶ãŒã®èŠåïŒ V204 32ãããæŽæ°åãããã€ã³ã¿ãŒåãžã®æ瀺çãªå€æïŒïŒJABBER_LIST_ITEM *ïŒres test.cpp 57
ãŸãããã®ã³ãŒãã§äœ¿çšãããŠãããTrackPopupMenuãé¢æ°ãèŠãŠã¿ããšããã§ãããã ãŠãŒã¶ãŒãéžæããã¡ãã¥ãŒé ç®ã®èå¥åãè¿ããŸãããšã©ãŒã®å Žåãéžæè¢ããªãã£ãå Žåã¯nullå€ãè¿ããŸãã ãããã®ç®çã§ãBOOLããšå ¥åãããšãæããã«å€±æããŸãããã©ãããã°ããã§ããã
ãã®é¢æ°ã®å®è¡çµæã¯ãã³ãŒããããããããã«ãå€æ°ãresãã«å ¥åãããŸãã ããã§ãäžéšã®èŠçŽ ããŠãŒã¶ãŒã«ãã£ãŠéžæãããå ŽåïŒresïŒ= 0ïŒããã®å€æ°ã¯æ§é äœãžã®ãã€ã³ã¿ãŒã«ãã£ã¹ããããŸãã èå³æ·±ãã¢ãããŒãã§ããããã®èšäºã§ã¯64ããããšã©ãŒã«ã€ããŠèª¬æããŠããã®ã§ããã®ã³ãŒãã32ãããããã³64ãããã¢ãŒããã¯ãã£ã§ã©ã®ããã«å®è¡ããããããããŠäœãåé¡ã«ãªãã®ãèããŠã¿ãŸãããã
ãã£ããã¯ã32ãããã¢ãŒããã¯ãã£ã§ã¯ãããã€ã³ã¿ãŒããšãããŒã«ãã®åãåããµã€ãºã§ããããããã®ãããªå€æã¯åãå ¥ãå¯èœã§å®è¡å¯èœã§ãããšããããšã§ãã ãããããã®ã¬ãŒãã¯64ãããã¢ãŒããã¯ãã£ã§æããããŸãã Win64ã¢ããªã±ãŒã·ã§ã³ã§ã¯ãäžèšã®ã¿ã€ãã®ãµã€ãºã¯ç°ãªããŸãïŒãããã64ããããš32ãããïŒã æœåšçãªãšã©ãŒã¯ããã€ã³ã¿ãŒã®æäžäœãããã倱ãããå¯èœæ§ãããããšã§ãã
ã¬ãã¥ãŒãç¶ç¶ããŸãã ã³ãŒãã¹ããããïŒ
static int hash_void_ptr(void *ptr) { int hash; int i; hash = 0; for (i = 0; i < (int)sizeof(ptr) * 8 / TABLE_BITS; i++) { hash ^= (unsigned long)ptr >> i * 8; hash += i * 17; hash &= TABLE_MASK; } return hash; }
ã¢ãã©ã€ã¶ãŒã®èŠåïŒ V205ãã€ã³ã¿ãŒåãã32ãããæŽæ°åãžã®æ瀺çãªå€æïŒïŒç¬Šå·ãªãlongïŒptr test.cpp 76
ãã®é¢æ°ã§ãvoid *ãåã®å€æ°ããunsigned longãåã«ãã£ã¹ãããåé¡ãäœã§ããããèŠãŠã¿ãŸãããã æ¢ã«è¿°ã¹ãããã«ããããã®ã¿ã€ãã¯LLP64ããŒã¿ã¢ãã«ã§ãµã€ãºãç°ãªãããvoid *ãã¿ã€ãã¯64ããããå æãããunsigned longãã¯32ãããã§ãã ãã®çµæãå€æ°ãptrãã«å«ãŸããäžäœãããã¯åãæšãŠãããŸãïŒå€±ãããŸãïŒã ãã®çµæãå€æ° 'i'ã®å€ã¯å埩ãé²ãã«ã€ããŠå¢å ããŸããå埩ãé²ãã«ã€ããŠãããåäœã§å³ã«ã·ãããããšãå¢å ãããããæ°ã«åœ±é¿ããŸãã å€æ° 'ptr'ã®ãµã€ãºã¯åãæšãŠãããŠãããããããå埩ãããããã«å«ãŸãããã¹ãŠã®ãããã0ã§åããããŸããäžèšã®ãã¹ãŠã®çµæ-Win64ããŒã¹ã®ã¢ããªã±ãŒã·ã§ã³ã§ã¯ã 'hash'ã¯æ£ããã³ã³ãã€ã«ãããŸããã ãããã·ã¥ãã«ãŒããå ¥åãããšã è¡çªãçºçããå¯èœæ§ããããŸããã€ãŸããç°ãªãå ¥åããŒã¿ïŒãã®å Žåã¯ãã€ã³ã¿ãŒïŒã«å¯ŸããŠåãããã·ã¥ãååŸããŸãã ãã®çµæãããã¯éå¹ççãªããã°ã©ã æäœã«ã€ãªããå¯èœæ§ããããŸãã 'memsize type'ãžã®ãã£ã¹ããå®è¡ãããå ŽåãåãæšãŠã¯è¡ããããã·ããïŒãããã£ãŠããã·ã¥ã®ã³ã³ãã€ã«ïŒãæ£ããå®è¡ãããŸãã
次ã®ã³ãŒããèŠãŠã¿ãŸãããã
class CValueList : public CListCtrl { .... public: BOOL SortItems(_In_ PFNLVCOMPARE pfnCompare, _In_ DWORD_PTR dwData); .... }; void CLastValuesView::OnListViewColumnClick(....) { .... m_wndListCtrl.SortItems(CompareItems, (DWORD)this); .... }
ã¢ãã©ã€ã¶ãŒã®èŠåïŒ V220åãã£ã¹ãã®äžå¯©ãªã·ãŒã±ã³ã¹ïŒmemsize-> 32ãããæŽæ°-> memsizeã ãã£ã¹ããããå€ïŒ 'this'ã test.cpp 87
Diagnostics V220ã¯ãäºéã®å±éºãªããŒã¿å€æãéç¥ããŸãã æåã«ããmemsize typeãã®å€æ°ã¯32ãããå€ã«ãªããããã«ãmemsize typeãã«æ»ããŸãã å®éãããã¯æäžäœãããã®å€ããã«ãããªãããããããšãæå³ããŸãã ããã¯ã»ãšãã©ã®å Žåééãã§ãã
å±éºãªå€æã®ãããã¯ã«ã€ããŠã¯ãåŒãç¶ãæ¡åŒµããŸãã
#define YAHOO_LOGINID "yahoo_id" DWORD_PTR __cdecl CYahooProto::GetCaps(int type, HANDLE /*hContact*/) { int ret = 0; switch (type) { .... case PFLAG_UNIQUEIDSETTING: ret = (DWORD_PTR)YAHOO_LOGINID; break; .... } return ret; }
ã¢ãã©ã€ã¶ãŒã®èŠåïŒ V221åãã£ã¹ãã®çãããã·ãŒã±ã³ã¹ïŒãã€ã³ã¿ãŒ-> memsize- > 32ãããæŽæ°ã ãã£ã¹ããããå€ïŒ '"yahoo_id"'ã test.cpp 99
ç§ã¯ãå€æã®åäŸã§ãŸããŸãå€ããªãåŸåã«æ°ã¥ããŸããã äžèšã®ãã¹ãŠãšåãçç±ã§ãæ倧3ã€ããããã®ãã¡2ã€ã¯å±éºã§ãã ãYAHOO_LOGINIDãã¯æååãªãã©ã«ã§ããããããã®ã¿ã€ãã¯ãconst char *ãã§ããã64ãããã¢ãŒããã¯ãã£ã§ã¯ãDWORD_PTRãã¿ã€ããšåããµã€ãºã§ãããããæ瀺çãªå€æã¯æ£ããã§ãã ãããããã®åŸãæªãããšãå§ãŸããŸãã åãDWORD_PTRãã¯ãæé»çã«32ãããæŽæ°ã«ãã£ã¹ããããŸãã ããããããã ãã§ã¯ãããŸããã é¢æ°ã«ãã£ãŠè¿ãããçµæ㯠'DWORD_PTR'ã¿ã€ãã§ãããããå¥ã®æé»çãªå€æãå®è¡ãããä»å㯠'memsizeã¿ã€ã'ã«æ»ããŸãã æããã«ããã®å Žåãæ»ãå€ã®äœ¿çšã¯ããªãèªèº«ã®è²¬ä»»ã§ãã
Visual Studio 2013ã³ã³ãã€ã©ã次ã®ãããªèŠåãçºè¡ããããšã«æ³šæããŠãã ããã
èŠåC4244ïŒã=ãïŒãDWORD_PTRããããintããžã®å€æãããŒã¿ã®æ倱ã®å¯èœæ§
å®éã®è³ªåã¯ããã§å¯èœã«ãªããŸãïŒVisual Studio 2013ã«ãã£ãŠçºè¡ãããèŠåããã®äŸã§ã®ã¿è¡šç€ºãããã®ã¯ãªãã§ããïŒ è³ªåã¯å ¬å¹³ã§ãããå¿è匷ããããã¯ä»¥äžã«æžãããŸãã
ãããŸã§ã®éããšã©ãŒã®æ€èšãç¶ããŠããŸãã ã¯ã©ã¹éå±€ãå«ã次ã®ã³ãŒããæ€èšããŠãã ããã
class CWnd : public CCmdTarget { .... virtual void WinHelp(DWORD_PTR dwData, UINT nCmd = HELP_CONTEXT); .... }; class CFrameWnd : public CWnd { .... }; class CFrameWndEx : public CFrameWnd { .... virtual void WinHelp(DWORD dwData, UINT nCmd = HELP_CONTEXT); .... };
ã¢ãã©ã€ã¶ãŒã®èŠåïŒ V301äºæããªãé¢æ°ã®ãªãŒããŒããŒãåäœã 掟çã¯ã©ã¹ãCFrameWndExãããã³åºæ¬ã¯ã©ã¹ãCWndãã®é¢æ°ãWinHelpAãã®æåã®åŒæ°ãåç §ããŠãã ããã test.cpp 122
äŸã¯ãVisual C ++ 2012ã©ã€ãã©ãªããã§ãã¯ãããšãã«ã¬ããŒãããååŸããããšããç¹ã§èå³æ·±ãã§ãããã芧ã®ããã«ãVisual C ++éçºè ã§ãã64ããããšã©ãŒãäœæããŸãã
ãã®ãšã©ãŒã«é¢ãã詳现ã¯ã 察å¿ããèšäºã«èšèŒãããŠããŸã ã ããã§ãã®æ¬è³ªãç°¡åã«èª¬æãããã£ãã 32ãããã¢ãŒããã¯ãã£ã§ã¯ããDWORDããšãDWORD_PTRãã®ã¿ã€ããåããµã€ãºã§ããããããã®ã³ãŒãã¯æ£ããåŠçãããŸããåŸç¶ã¯ã©ã¹ã§ã¯ããã®é¢æ°ããªãŒããŒã©ã€ããããã³ãŒããæ£ããå®è¡ãããŸãã ããããèœãšãç©Žã¯ãŸã ããã«ããã64ãããã¢ãŒããã¯ãã£ã§èªåèªèº«ã«ã€ããŠç¥ãããšãã§ããŸãã ãã®å Žåãã¿ã€ããDWORDããšãDWORD_PTRãã®ãµã€ãºã¯ç°ãªããããããªã¢ãŒãã£ãºã ã¯ç Žæ£ãããŸãã 2ã€ã®ç°ãªãæ©èœãæå ã«çšæããŸãããããã¯æå³ãããã®ã«åããŸãã
ãããŠæåŸã®äŸïŒ
void CSymEngine::GetMemInfo(CMemInfo& rMemInfo) { MEMORYSTATUS ms; GlobalMemoryStatus(&ms); _ultot_s(ms.dwMemoryLoad, rMemInfo.m_szMemoryLoad, countof(rMemInfo.m_szMemoryLoad), 10); .... }
ã¢ãã©ã€ã¶ãŒã®èŠåïŒ V303é¢æ° 'GlobalMemoryStatus'ã¯ãWin64ã·ã¹ãã ã§ã¯éæšå¥šã§ãã 'GlobalMemoryStatusEx'é¢æ°ã䜿çšããæ¹ãå®å šã§ãã test.cpp 130
ååãšããŠãç¹å¥ãªèª¬æã¯å¿ èŠãããŸãããã¢ãã©ã€ã¶ãŒã®ã¡ãã»ãŒãžãããã¹ãŠãæããã§ãã ãGlobalMemoryStatusãé¢æ°ã¯64ãããã¢ãŒããã¯ãã£ã§ã¯æ£ããåäœããªãå¯èœæ§ãããããããGlobalMemoryStatusExãé¢æ°ã䜿çšããå¿ èŠããããŸãã 詳现ã«ã€ããŠã¯ãMSDN ã®å¯Ÿå¿ããé¢æ°ã®èª¬æãåç §ããŠãã ããã
ã泚æ
äžèšã®ãšã©ãŒã¯ãã¹ãŠãæãäžè¬çãªã¢ããªã±ãŒã·ã§ã³ãœãããŠã§ã¢ã§çºçããå¯èœæ§ãããããšã«æ³šæããŠãã ããã ããããçºçããããã«ãããã°ã©ã ã¯å€§éã®ã¡ã¢ãªã§åäœããå¿ èŠã¯ãããŸããã ãããŠãããããããã®ãšã©ãŒãæ€åºãã蚺æãæåã®ã¬ãã«ã«å±ããçç±ã§ãã
Visual Studio 2013ã¯äœãäŒããŸããïŒ
ã³ã³ãã€ã©ã®èŠå
Visual Studio 2013ã§éçã¢ãã©ã€ã¶ãŒããã§ãã¯ããçµæã«ã€ããŠèª¬æããåã«ãã³ã³ãã€ã©ãŒã®èŠåã«ã€ããŠè©³ãã説æããŸãã æ°é ãã®ããèªè ã¯ããããããã®ãããªèŠåãããã¹ãã§1ã€ã ãäžããããŠããããšã«æ°ã¥ããã§ãããã åé¡ã¯äœã§ããïŒ ããããå®éã«ã¯ã64ããããšã©ãŒã«é¢é£ããèŠåã¯ãããããŸããã§ããã ãããŠãããã¯èŠåãçºè¡ãã第3ã¬ãã«ã§ãã
ãã ãããã¹ãŠã®èŠåãæå¹ã«ããŠïŒEnableAllWarningsïŒããã®äŸãã³ã³ãã€ã«ãã䟡å€ããããŸãã
ããã«ãéåžžã«äºæãããèŠåãããããŒãã¡ã€ã«ïŒwinnt.hãªã©ïŒã«ã€ãªãããŸãã ããªããããŸãã«ãæ zyã§ã¯ãªãããã®èŠåã®å±±ã§ãããžã§ã¯ãã«é¢é£ãããã®ãèŠã€ããå Žåãããªãã¯ãŸã äœãé¢çœããã®ãæœåºããããšãã§ããŸããäŸãã°ïŒ
èŠåC4312ïŒ 'åãã£ã¹ã'ïŒ 'int'ãã 'JABBER_LIST_ITEM *'ãžã®å€§ããªãµã€ãºã®å€æ
èŠåC4311ïŒãåãã£ã¹ããïŒãvoid *ããããunsigned longããžã®ãã€ã³ã¿ãŒã®åãæšãŠ
èŠåC4311ïŒãåãã£ã¹ããïŒãCLastValuesView * constããããDWORDããžã®ãã€ã³ã¿ãŒã®åãæšãŠ
èŠåC4263ïŒ 'void CFrameWndEx :: WinHelpAïŒDWORDãUINTïŒ'ïŒã¡ã³ããŒé¢æ°ã¯ãåºæ¬ã¯ã©ã¹ã®ä»®æ³ã¡ã³ããŒé¢æ°ããªãŒããŒã©ã€ãããŸãã
äžè¬ã«ãã³ã³ãã€ã©ã¯ãããã®äŸãå«ããã¡ã€ã«ã§10åã®èŠåãçºè¡ããŸããã ãã®ãªã¹ãã®3ã€ã®èŠåã®ã¿ã64ããããšã©ãŒãæ確ã«ç€ºããŠããŸãïŒã³ã³ãã€ã©èŠåC4311ããã³C4312ïŒã ãããã®èŠåã®äžã«ã¯ãçµã蟌ã¿åå€æïŒC4244ïŒã瀺ããã®ããä»®æ³é¢æ°ããªãŒããŒã©ã€ããããªããã®ïŒC4263ïŒããããŸãã ãããã®èŠåã¯ã64ããããšã©ãŒãéæ¥çã«ç€ºããŠããŸãã
ãã®çµæãäœããã®æ¹æ³ã§ç¹°ãè¿ãç¹°ãè¿ãããèŠåãé€å€ãããšãæ€èšäžã®64ããããšã©ãŒã«é¢ãã5ã€ã®èŠåã衚瀺ãããŸãã
ã芧ã®ãšãããVisual Studioã³ã³ãã€ã©ã¯ãã¹ãŠã®64ããããšã©ãŒãæ€åºã§ããŸããã§ããã PVS-Studioã¢ãã©ã€ã¶ãŒãåããã¡ã€ã«ã§æåã®ã¬ãã«ã®9ã€ã®ãšã©ãŒãæ€åºããããšãæãåºããŸãã
ãããããVisual Studio 2013ã«çµã¿èŸŒãŸããŠããéçã¢ãã©ã€ã¶ãŒã¯ã©ãã§ããïŒã ãã¶ãã圌ã¯ããè¯ãããŠãããå€ãã®ééããèŠã€ããŸãããïŒ èŠãŠã¿ãŸãããã
Visual Studio 2013ã«å«ãŸããéçã¢ãã©ã€ã¶ãŒ
Visual Studio 2013ã«çµã¿èŸŒãŸããéçã¢ãã©ã€ã¶ãŒã§ãããã®äŸããã§ãã¯ããçµæã3ã€ã®èŠåããããŸããã
- C6255 allocaã®ä¿è·ãããŠããªã䜿çš
_allocaã¯ãã¹ã¿ãã¯ãªãŒããŒãããŒäŸå€ãçºçãããããšã§å€±æã瀺ããŸãã 代ããã«_mallocaã®äœ¿çšãæ€èšããŠãã ããã
64BitsErrors-test.cppïŒ58è¡ç®ïŒ; - C6384ãã€ã³ã¿ãŒãµã€ãºã®åå²
ãã€ã³ã¿ãŒã®ãµã€ãºãå¥ã®å€ã§é€ç®ããŸãã
64BitsErrors-test.cppïŒè¡72ïŒ; - C28159代ããã«å¥ã®é¢æ°ã®äœ¿çšãæ€èšããŠãã ãã
ãGlobalMemoryStatusãã®ä»£ããã«ãGlobalMemoryStatusExãã®äœ¿çšãæ€èšããŠãã ããã çç±ïŒå»æ¢ãããŸããã 詳现ã«ã€ããŠã¯ãMSDNãåç §ããŠãã ãã
64BitsErrors-test.cppïŒ128è¡ç®ïŒ;
ããããç§ãã¡ã¯64ããããšã©ãŒãèŠãŠããŸãããïŒ ãã®ãªã¹ãããããã€ã®ãšã©ãŒã64ãããã«é©çšãããŸããïŒ åŸè ã®ã¿ïŒèª€ã£ãçµæãè¿ãå¯èœæ§ã®ããé¢æ°ã䜿çšïŒã
Visual Studio 2013éçã¢ãã©ã€ã¶ãŒã¯ãPVS-Studioã¢ãã©ã€ã¶ãŒã«ãã£ãŠæ€åºããã9ã«å¯ŸããŠ1 64ããããšã©ãŒãæ€åºããããšãããããŸããã å°è±¡çã§ããã 倧èŠæš¡ãªãããžã§ã¯ãã®éããæ³åããŠãã ããã
ãããŠããšã©ãŒæ€åºã«é¢ããæ©èœã®èŠ³ç¹ãããVisual Studio 2013ç°å¢ãšVisual Studio 2015ç°å¢ã«çµã¿èŸŒãŸããéçã³ãŒãã¢ãã©ã€ã¶ãŒã¯åãã§ããããšãããäžåºŠæãåºããŠãããŸãïŒè©³çŽ°ã«ã€ããŠã¯ã 察å¿ãã泚ã§èª¬æããŸãïŒã
çµæã¯äœã§ããïŒ
æãæ確ãªã®ã¯ãã³ãŒãäŸã®æ€èšŒçµæã衚圢åŒã§åæ ããããšã§ãã
è¡šãããããããã«ã9åã®64ããããšã©ãŒãPVS-Studioã䜿çšããŠæ€åºããã6åãMicrosoft Visual Studio 2013ã®äžè¬çãªæ段ã«ãã£ãŠæ€åºãããŸããããããããããã¯ããã»ã©å€§ããªéãã§ã¯ãªãã§ãããã ç§ã¯åæããŸããã çç±ãç解ããŸãããïŒ
- æãéèŠãª64ããããšã©ãŒã«ã€ããŠã®ã¿èª¬æããŸããã ãã¹ãããšã©ãŒã3ã€ã§ããããã¯ãããããããŸãã ãããŠãPVS-Studioã¢ãã©ã€ã¶ãŒã第2ããã³ç¬¬3ã¬ãã«ã®èŠåãçæããããããŸããªãšã©ãŒãååŸãããšãVisual Studioãããã¯ããã«å€ãã®ãšã©ãŒãèŠã€ããããšãã§ããŸãã ããã«ã€ããŠã®äœããã®èãããã®èšäºãäžããŸã ã ãã®èšäºã¯å°ãæ代é ãã§ãããä»ã§ã¯ã®ã£ããã¯ããã«å€§ãããªããŸãã
- 4çªç®ã®èŠåã¬ãã«ããªã³ã«ããŠã³ã³ãã€ã©ãŒã«ãã«ããæ±ããããšã¯ãåžžã«å¯èœã§ã¯ãããŸããã ãã ãã4çªç®ãš3çªç®ã®ã¬ãã«ã®èŠåã§ã¯ã64ããããšã©ãŒã«é¢é£ããèŠåïŒã¢ãã©ã€ã¶ãŒãšã³ã³ãã€ã©ãŒã䜿çšïŒã¯2ã€ãã衚瀺ãããŸããã ããŸãå°è±¡çãªçµæã§ã¯ãããŸããã
- ã/ Wallããã©ã°ãèšå®ãããšããããžã§ã¯ãã«é¢é£ããªãèŠåã倧éã«è¡šç€ºãããŸãã å®éã«ã¯ãã/ Wallãã®äœ¿çšã¯å°é£ã§ãã ããã€ãã®èŠåãåå¥ã«ãªã³ã«ããããšãã§ããŸãããããã§ãå€ãã®éå°ãªãã€ãºãæ®ã£ãŠããŸãã
äžèšãããããããã«ãMicrosoft Visual Studio 2013ã§æ€åºããã64ããããšã©ãŒãæ€åºããã«ã¯ãããçšåºŠã®äœæ¥ãè¡ãå¿ èŠããããŸãã ãããã©ãã ãå¢å ãããæ³åããŠã¿ãŠãã ããããããæ¬åœã®ãæ¬åœã«å€§ããªãããžã§ã¯ãã§ãããªãã
PVS-Studioã¯ã©ãã§ããïŒ æ°åã®ããŠã¹ã¯ãªãã¯ã§èšºæãå®è¡ãã64ããããšã©ãŒãšå¿ èŠãªèŠåã®ãã£ã«ã¿ãªã³ã°ãèšå®ãããšãçµæãåŸãããŸãã
ãããã«
64ãããã¢ãŒããã¯ãã£ãžã®ã¢ããªã±ãŒã·ã§ã³ã®ç§»æ€ã«ã¯å€ãã®å°é£ã䌎ãããšã瀺ãããšãã§ãããšæããŸãã ãã®èšäºã§èª¬æãããããªãšã©ãŒã¯ç°¡åã«çºçããŸãããèŠã€ããã®ã¯éåžžã«å°é£ã§ãã ããã«ããã®ãããªãšã©ãŒã®ãã¹ãŠãMicrosoft Visual Studio 2013ã«ãã£ãŠæ€åºãããããã§ã¯ãªããšããäºå®ãšãç¹å®ã®äœæ¥ãè¡ãããã«å¿ èŠãªãšã©ãŒãèŠã€ããããã«è¿œå ããŸãã åæã«ã PVS-Studioéçã¢ãã©ã€ã¶ãŒã¯ã¿ã¹ã¯ã«å¯ŸåŠããé©åãªçµæã瀺ããŸããã ããã«ããšã©ãŒã®æ€çŽ¢ãšãã£ã«ã¿ãªã³ã°ã®ããã»ã¹ã¯ããç°¡åã§äŸ¿å©ã§ãã ãã®ãããªããŒã«ã䜿çšããªãæ¬åœã«å€§ããªãããžã§ã¯ãã§ã¯ãã¿ã€ãã«ããå¿ èŠãããããšãèªããªããã°ãªããŸããããã®ããããã®ãããªå Žåã«ã¯åªããéçã¢ãã©ã€ã¶ãŒãå¿ èŠã«ãªããŸãã
64ãããã¢ããªã±ãŒã·ã§ã³ãéçºããŠããŸããïŒ PVS-Studioãã©ã€ã¢ã«ãããŠã³ããŒããããããžã§ã¯ãããã§ãã¯ããŠãæåã®ã¬ãã«ã®64ãããã¡ãã»ãŒãžã®æ°ã確èªããŸãã ããã§ãããã€ã衚瀺ãããå Žåã¯ãããããä¿®æ£ããŠããã®äžçãå°ãè¯ãããŠãã ããã
è¿œå è³æ
çŽæã©ããã64ããããšã©ãŒã®ãããã¯ã«é¢ããè¿œå è³æã®ãªã¹ãã瀺ããŸãã
- çšèªã 64ããããšã©ãŒ ;
- ã¢ã³ãã¬ã€ã»ã«ã«ããã å®éã®ããã°ã©ã ã§ã®64ããããšã©ãŒã®äŸã®ã³ã¬ã¯ã·ã§ã³ ã
- ã¢ã³ãã¬ã€ã»ã«ã«ããã C ++ 11ããã³64ããããšã©ãŒ ã
- ã¢ã³ãã¬ã€ã»ã«ã«ããããšãã²ããŒã»ãªãºã³ãã 64ãããC / C ++ã¢ããªã±ãŒã·ã§ã³ã®éçºã®ããã®ã¬ãã¹ã³ ã
ãã®èšäºã¯è±èªã§ãã
ãã®èšäºãè±èªåã®èŽè¡ãšå ±æãããå Žåã¯ã翻蚳ãžã®ãªã³ã¯ã䜿çšããŠãã ããïŒSergey Vasilievã 2015幎ã®64ãããã³ãŒãïŒèããããåé¡ã®èšºæã®æ°æ©èœ ã
èšäºãèªãã§è³ªåããããŸããïŒ
å€ãã®å Žåãèšäºã«ã¯åã質åãå¯ããããŸãã ããã§åçãéããŸããïŒ PVS-StudioããŒãžã§ã³2015ã«é¢ããèšäºã®èªè
ããã®è³ªåãžã®åç ã ãªã¹ããã芧ãã ããã