https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71867
--- Comment #9 from asmwarrior <asmwarrior at gmail dot com> --- I see this crash issue again, but still it happens in another place of the wx's source code, add the __attribute__((optimize("O0"))) To the function which cause the crash can workaround this issue. Note that the -O0 option does not cause this issue. wxString __attribute__((optimize("O0"))) wxCommandEvent::GetString() const { // This is part of the hack retrieving the event string from the control // itself only when/if it's really needed to avoid copying potentially huge // strings coming from multiline text controls. For consistency we also do // it for combo boxes, even though there are no real performance advantages // in doing this for them. if (m_eventType == wxEVT_TEXT && m_eventObject) { #if wxUSE_TEXTCTRL wxTextCtrl *txt = wxDynamicCast(m_eventObject, wxTextCtrl); if ( txt ) return txt->GetValue(); #endif // wxUSE_TEXTCTRL #if wxUSE_COMBOBOX wxComboBox* combo = wxDynamicCast(m_eventObject, wxComboBox); if ( combo ) return combo->GetValue(); #endif // wxUSE_COMBOBOX } return m_cmdString; } Please see discussions here in wx-user's maillist and Code::Blocks's forum: https://groups.google.com/d/msg/wx-users/LUxm6fUhirk/FJRFNIt6AAAJ and http://forums.codeblocks.org/index.php/topic,22198.0.html The original wx's workaround is here: https://trac.wxwidgets.org/ticket/17483