From aa3acfdd15eff1519a41b48a2babe4cba75660f9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 13 Jul 2016 23:33:23 +0200 Subject: [PATCH] Work around an apparent gcc optimizer bug in wxClassInfo Rewrite a complex expression in wxClassInfo::IsKindOf() as several statements to avoid what looks like a gcc optimizer bug as it was dereferencing m_baseInfo1 pointer even when it was null. The new version is not completely equivalent to the old one as it doesn't check for info == NULL which is not really necessary, but this is just a side effect and doesn't affect anything, the important change is avoiding doing everything in a single expression. Closes #17483. --- include/wx/rtti.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/include/wx/rtti.h b/include/wx/rtti.h index 308b65767b..34d8d387bf 100644 --- a/include/wx/rtti.h +++ b/include/wx/rtti.h @@ -85,10 +85,22 @@ public: bool IsKindOf(const wxClassInfo *info) const { - return info != 0 && - ( info == this || - ( m_baseInfo1 && m_baseInfo1->IsKindOf(info) ) || - ( m_baseInfo2 && m_baseInfo2->IsKindOf(info) ) ); + if ( info == this ) + return true; + + if ( m_baseInfo1 ) + { + if ( m_baseInfo1->IsKindOf(info) ) + return true; + } + + if ( m_baseInfo2 ) + { + if ( m_baseInfo2->IsKindOf(info) ) + return true; + } + + return false; } wxDECLARE_CLASS_INFO_ITERATORS();