Opened 5 years ago

Closed 5 years ago

#15201 closed defect (fixed)

clang warning in wx/mousestate.h

Reported by: wojdyr Owned by:
Priority: low Milestone:
Component: GUI-all Version: stable-latest
Keywords: Cc:
Blocked By: Blocking:
Patch: no


I get:

/home/wojdyr/local/include/wx-2.9/wx/mousestate.h:106:13: warning: default label
      in switch which covers all enumeration values [-Wcovered-switch-default]
/home/wojdyr/local/include/wx-2.9/wx/mousestate.h:108:24: warning: will never be
      executed [-Wunreachable-code]
                return false;
2 warnings generated.

If the default: case is needed for some compilers, maybe it can be put after

 case wxMOUSE_BTN_MAX:

this would avoid the second warning.

(BTW recently I had a chance to work with github/bitbucket pull requests, it's a very convenient workflow. It would be nice if wxwidgets migrated to git in the future. According to github, svn access to their git repos also works.)

Change History (3)

comment:1 Changed 5 years ago by vadz

  • Status changed from new to confirmed

Would this

  • include/wx/mousestate.h

    diff --git a/include/wx/mousestate.h b/include/wx/mousestate.h
    index 98ab291..dcdce4d 100644
    a b class WXDLLIMPEXP_CORE wxMouseState : public wxKeyboardState 
    102102            case wxMOUSE_BTN_MAX:
    103103                wxFAIL_MSG(wxS("invalid parameter"));
    104104                return false;
    106             default:
    107                 wxFAIL_MSG(wxS("unknown parameter"));
    108                 return false;
    109105        }
     107        wxFAIL_MSG(wxS("unknown parameter"));
     108        return false;
    110109    }

or is it still going to complain about unreachable code after the switch?

BTW, which clang version do you use? Strange that I've never noticed this although I do test clang compilation occasionally (under Linux).

P.S. You needn't try to convince me about Git superiority in general and convenience of GitHub pull requests in particular, but this is not going to happen before 3.0. Maybe for 3.2 though...

comment:2 Changed 5 years ago by wojdyr

These warnings are not in -Wall, I played with various -W flags, so it's really important.
Your patch reduced one warning, unreachable-code is still there.

/home/wojdyr/local/include/wx-2.9/wx/mousestate.h:108:16: warning: will never be executed [-Wunreachable-code]
        return false;

comment:3 Changed 5 years ago by VZ

  • Resolution set to fixed
  • Status changed from confirmed to closed

(In [73972]) Fix harmless Clang warning about unreachable code.

Unfortunately Clang intelligent flow analysis prevents us from using different
asserts for invalid parameter value and unhandled one, which could happen if
more elements are added to wxMouseButton enum in the future.

Closes #15201.

Note: See TracTickets for help on using tickets.