Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CGridCtrlDemoDlg::UpdateMenuUI()
- {
- ...
- GetMenu()->CheckMenuItem(IDC_HORZ_LINES, MF_BYCOMMAND |
- (bHorzLines)? MF_CHECKED: MF_UNCHECKED);
- GetMenu()->CheckMenuItem(IDC_LISTMODE, MF_BYCOMMAND |
- (m_Grid.GetListMode())? MF_CHECKED: MF_UNCHECKED);
- GetMenu()->CheckMenuItem(IDC_VERT_LINES, MF_BYCOMMAND |
- (bVertLines)? MF_CHECKED: MF_UNCHECKED);
- GetMenu()->EnableMenuItem(IDC_SINGLESELMODE, MF_BYCOMMAND |
- (m_Grid.GetListMode())? MF_ENABLED: MF_DISABLED|MF_GRAYED);
- .....
- GetMenu()->CheckMenuItem(ID_HIDE2NDROWCOLUMN,
- MF_BYCOMMAND |
- (m_bRow2Col2Hidden)? MF_CHECKED: MF_UNCHECKED);
- ...
- }
- This code is incorrect as the priority of '?:' operator is lower than of '|'.
- The program works correctly because of MF_BYCOMMAND == 0.
- Nonetheless this code is potentially dangerous.
- This suspicious code was found in gridctrl_redux project by PVS-Studio static code analyzer.
- Warning message is:
- V502 Perhaps the '?:' operator works in a different way than it was expected. The '?:' operator has a lower priority than the '|' operator.
- PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment