https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71867
--- Comment #10 from asmwarrior <asmwarrior at gmail dot com> --- Is it related to pointer casting? I see this post: https://stackoverflow.com/questions/36816363/gcc-4-9-3-more-aggressive-null-pointer-check-removal Some one reported that the Null check was removed in the following code void someFunc(struct MyStruct *s) { if (s != NULL) { cout << s->someField << endl; delete s; } } I see comments in that question, and some one suggest using `-fno-strict-aliasing` option. @Vadim, dose wx use some cast? I see some macros in wx3.1's source like: // this cast does some more checks at compile time as it uses static_cast // internally // // note that it still has different semantics from dynamic_cast<> and so can't // be replaced by it as long as there are any compilers not supporting it #define wxDynamicCast(obj, className) \ ((className *) wxCheckDynamicCast( \ const_cast<wxObject *>(static_cast<const wxObject *>(\ const_cast<className *>(static_cast<const className *>(obj)))), \ &className::ms_classInfo))