15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


STATIC_DOWNCAST bug when used on const pointers?

Niels Ull Jacobsen -- nuj@kruger.dk
Wednesday, May 01, 1996

VC++ 4.1, MFC 4.1, Win95


I run into an infinite recursion when using STATIC_DOWNCAST on a const=
 pointer.

In afx.inl, line 38-41, I find:=20


#ifdef _DEBUG
_AFX_INLINE const CObject* AFX_CDECL AfxStaticDownCast(CRuntimeClass*
pClass, const CObject* pObject)
	{ return (CObject*)AfxStaticDownCast(pClass, (const CObject*)pObject); }
#endif

This gives an endless recursion.
I think it should be

_AFX_INLINE const CObject* AFX_CDECL AfxStaticDownCast(CRuntimeClass*
pClass, const CObject* pObject)
    { return (const CObject*)AfxStaticDownCast(pClass, const_cast 
pObject); }
Niels Ull Jacobsen, Kr=FCger A/S (nuj@kruger.dk)
Everything stated herein is THE OFFICIAL POLICY of the entire Kruger group
and should be taken as legally binding in every respect. Pigs will grow
wings and fly.








Mike Blaszczak -- mikeblas@interserv.com
Wednesday, May 01, 1996

On Wed, 01 May 1996, Niels Ull Jacobsen  wrote:

>I run into an infinite recursion when using STATIC_DOWNCAST
>on a const pointer.

Yep.  It's been fixed for MFC 4.2.  Since I fixed it, I probably broke 
something else at the same time.  For now, you'll have to cast away 
constness.

.B ekiM
TCHAR szDisc[] = _T("These words are my own; I do not speak for Microsoft.");





| Вернуться в корень Архива |