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.
This commit is contained in:
Vadim Zeitlin
2016-07-13 23:33:23 +02:00
parent 3057c18939
commit aa3acfdd15

View File

@@ -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();