Re: Function's default values are corrupted (Nasty bug)
Re: Function's default values are corrupted (Nasty bug)
- Subject: Re: Function's default values are corrupted (Nasty bug)
- From: Dave Thorup <email@hidden>
- Date: Fri, 1 Apr 2005 12:35:58 -0500
I've tracked the problem down. It seems that the Template Class that
defines SetSize is also an internal class that's defined inside of
another class. I hadn't noticed this before since it's all defined in
a rather large header file and I wasn't the one who wrote it.
Anyway, here's a simple test case that you're free to try out. I'll
have a pre-built project posted to my website soon and then I'll write
up a bug report, but just incase anyone else wants to try this out
right away here it is. All you need to do is create an instance of
CJunkOverlord and that will call SetSize in its constructor.
Enjoy!
_____________________________
Dave Thorup
Software Engineer
email@hidden
http://www.kuwan.net
Defaults Manager - The premier editor for Mac OS X's User Defaults /
Preferences database.
---------------------------------------------------------
#include <iostream>
/**
* This class demonstrates the incorrect behavior.
*/
class CJunkOverlord
{
template <class T>
class TJunkInternal
{
public:
TJunkInternal( void ) { x = 0; }
/**
* This version of SetSize displays the incorrect behavior.
* I seem to have narrowed the problem down to this simple test case.
* When TJunkInternal is defined as a class inside of another class
(CJunkOverlord)
* then SetSize doesn't work properly. If TJunkInternal is defined
outside of
* CJunkOverlord then it works properly.
*/
void SetSize( unsigned long nWd, unsigned long nHt,
long nEx1 = -1, long nEx2 = -1, long nEx3 = -1, long nEx4 = -1 )
{
std::cout << "CJunkOverlord::TJunkInternal::SetSize (Incorrect)"
<< std::endl;
std::cout << " nWd=" << nWd << ", nHt=" << nHt << ", nEx1=" << nEx1
<< ", nEx2=" << nEx2 << ", nEx3=" << nEx3 << ", nEx4=" << nEx4
<< std::endl << std::endl;
}
// just a stupid little method that does something
T Inc()
{
x++;
return x;
}
T x;
};
public:
CJunkOverlord( )
{
m_Junk.SetSize( 800, 600, 20 );
}
protected:
TJunkInternal<unsigned short> m_Junk;
};
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden