Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Bug in Core06.cpp or in U++ Core value types tutorial
Bug in Core06.cpp or in U++ Core value types tutorial [message #12969] Sat, 01 December 2007 12:54 Go to next message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member
Core06.exe yields:

Quote:

...
a.Is<int>() = false
a.Is<double>() = false
b.Is<double>() = false
c.Is<int>() = false
c.Is<Date>() = true
d.Is<String>() = true
...



U++ Core value types tutorial, 6. Value, says:

Quote:


a.Is<int>() = true
a.Is<double>() = false
b.Is<double>() = true
c.Is<int>() = false
c.Is<Date>() = true
d.Is<String>() = true



Who is right?

Werner

Re: Bug in Core06.cpp or in U++ Core value types tutorial [message #13010 is a reply to message #12969] Wed, 05 December 2007 12:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
This is a complete output from quick test:

* c:\out\MSC71cdb.Debug_full\Core06.exe 05.12.2007 12:04:53, user: Luzr

x = 1
y = 2.34
z = 12/05/2007
s = hello
i = 1
j = 2
k = 12/05/2007
t = hello
a.Is<int>() = true
a.Is<double>() = false
b.Is<double>() = true
c.Is<int>() = false
c.Is<Date>() = true
d.Is<String>() = true
IsNumber(a) = true
IsNumber(b) = true
IsDateTime(c) = true


Does seem all right to me. However, tested with MSC71 in WinXP.

It is however possible that the problem is compiler / platform related. Can you perhaps provide more information please? Also about U++ version?

Mirek
Re: Bug in Core06.cpp or in U++ Core value types tutorial [message #13017 is a reply to message #13010] Wed, 05 December 2007 14:29 Go to previous messageGo to next message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member
luzr wrote on Wed, 05 December 2007 12:07

This is a complete output from quick test:

* c:\out\MSC71cdb.Debug_full\Core06.exe 05.12.2007 12:04:53, user: Luzr

x = 1
y = 2.34
z = 12/05/2007
s = hello
i = 1
j = 2
k = 12/05/2007
t = hello
a.Is<int>() = true
a.Is<double>() = false
b.Is<double>() = true
c.Is<int>() = false
c.Is<Date>() = true
d.Is<String>() = true
IsNumber(a) = true
IsNumber(b) = true
IsDateTime(c) = true


Does seem all right to me. However, tested with MSC71 in WinXP.

It is however possible that the problem is compiler / platform related. Can you perhaps provide more information please? Also about U++ version?

Mirek


Sorry for the wrong forum section.

I'm running upp-mingw-711-dev2.

I got my results building the original core06.cpp example using gcc 4.2.1 under Windows XP.

Werner

[Updated on: Wed, 05 December 2007 14:40]

Report message to a moderator

Re: Bug in Core06.cpp or in U++ Core value types tutorial [message #13018 is a reply to message #13017] Wed, 05 December 2007 14:59 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
[quote title=Werner wrote on Wed, 05 December 2007 08:29]
luzr wrote on Wed, 05 December 2007 12:07

This is a complete output from quick test:

I'm running upp-mingw-711-dev2.

I got my results building the original core06.cpp example using gcc 4.2.1 under Windows XP.

Werner



Thank you. Bug reproduced and fixed (templates are implemented according to standard in GCC... while MSC interpreted certain code as I wanted.... Smile.

To be sure, please replace these in Value.h:

template <class T>
inline dword ValueTypeNo(const T&)       { return StaticTypeNo<T>() + 0x8000000;; }

template<> inline dword ValueTypeNo(const int&)     { return INT_V; }
template<> inline dword ValueTypeNo(const int64&)   { return INT64_V; }
template<> inline dword ValueTypeNo(const double&)  { return DOUBLE_V; }
template<> inline dword ValueTypeNo(const bool&)    { return BOOL_V; }
template<> inline dword ValueTypeNo(const String&)  { return STRING_V; }
template<> inline dword ValueTypeNo(const WString&) { return WSTRING_V; }
template<> inline dword ValueTypeNo(const Date&)    { return DATE_V; }
template<> inline dword ValueTypeNo(const Time&)    { return TIME_V; }

template <class T, dword type, class B = EmptyClass>
class AssignValueTypeNo : public B {
public:
	friend dword ValueTypeNo(const T&)                  { return type; }

	void operator=(const AssignValueTypeNo&) {} // MSC 6.0 empty base class bug fix
};

template <class T>
bool IsType(const Value& x, T* = 0)           { return ValueTypeNo(*(T *)NULL) == x.GetType(); }

template <class T>
inline bool Value::Is() const
{
	return IsType<T>(*this);
}


..and test..

Mirek

[Updated on: Wed, 05 December 2007 15:00]

Report message to a moderator

Re: Bug in Core06.cpp or in U++ Core value types tutorial [message #13026 is a reply to message #13018] Wed, 05 December 2007 18:29 Go to previous message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member
luzr wrote on Wed, 05 December 2007 14:59


Thank you. Bug reproduced and fixed (templates are implemented according to standard in GCC... while MSC interpreted certain code as I wanted.... Smile.

To be sure, please replace these in Value.h:

template <class T>
inline dword ValueTypeNo(const T&)       { return StaticTypeNo<T>() + 0x8000000;; }

template<> inline dword ValueTypeNo(const int&)     { return INT_V; }
template<> inline dword ValueTypeNo(const int64&)   { return INT64_V; }
template<> inline dword ValueTypeNo(const double&)  { return DOUBLE_V; }
template<> inline dword ValueTypeNo(const bool&)    { return BOOL_V; }
template<> inline dword ValueTypeNo(const String&)  { return STRING_V; }
template<> inline dword ValueTypeNo(const WString&) { return WSTRING_V; }
template<> inline dword ValueTypeNo(const Date&)    { return DATE_V; }
template<> inline dword ValueTypeNo(const Time&)    { return TIME_V; }

template <class T, dword type, class B = EmptyClass>
class AssignValueTypeNo : public B {
public:
	friend dword ValueTypeNo(const T&)                  { return type; }

	void operator=(const AssignValueTypeNo&) {} // MSC 6.0 empty base class bug fix
};

template <class T>
bool IsType(const Value& x, T* = 0)           { return ValueTypeNo(*(T *)NULL) == x.GetType(); }

template <class T>
inline bool Value::Is() const
{
	return IsType<T>(*this);
}


..and test..

Mirek


Thanks. Now works as expected.

Just to do a quick test, I built TheIDE using gcc 4.2.1 with "MinGW Debug" and "MinGW Optimal". No problems, too.

Werner
Previous Topic: Question / Issue about Vector
Next Topic: <<= and <<
Goto Forum:
  


Current Time: Tue Apr 16 08:42:16 CEST 2024

Total time taken to generate the page: 0.54009 seconds