[fdo][FDO123][New] Invalid cast between unrelated types in the FdoRdbmsMySqlCon...
Mateusz Loskot
mateusz at loskot.net
Thu Aug 17 13:14:12 EDT 2006
You can view the artifact detail at the following URL:
https://fdo.osgeo.org/servlets/Scarab/id/FDO123
Type
Defect
Artifact ID
FDO123 (Invalid cast between unrelated types in the FdoRdbmsMySqlConnectionInfo class)
Reported by
Mateusz Loskot
mloskot (mateusz at loskot.net)
New artifact details:
---------------------------------------------------------
- OS Distribution and Version set to new value
Ubuntu 6.06
- Summary set to new value
Invalid cast between unrelated types in the FdoRdbmsMySqlConnectionInfo class
- Artifact created
- Steps to Reproduce set to new value
Analyse the code of the FdoRdbmsMySqlConnectionInfo::GetConnectionProperties()
and components used inside.
- Description set to new value
There is invalid cast in the GetConnectionProperties() function member of the FdoRdbmsMySqlConnectionInfo class.
Here I paste its body:
FdoIConnectionPropertyDictionary*
FdoRdbmsMySqlConnectionInfo::GetConnectionProperties()
{
if (mPropertyDictionary == NULL)
mPropertyDictionary = (FdoIConnectionPropertyDictionary *)new FdoRdbmsMySqlConnectionPropertyDictionary(mConnection);
FDO_SAFE_ADDREF(mPropertyDictionary);
return mPropertyDictionary;
}
Here, the mConnection data member is casted to FdoIConnectionPropertyDictionary type.
But the type of mConnection is FdoRdbmsMySqlConnectionPropertyDictionary, which in turn is unrelated (not in IS-A relation) to
the target type FdoIConnectionPropertyDictionary.
Here is small case study that illustrates the problem better:
struct A {};
struct B : public A {};
struct C {};
int main()
{
B* b = new B();
A* a = 0;
// OK and recommended
a = static_cast<A*>(b);
// OK but not recommended
a = (A*)b;
C* c = 0;
// Invalid and reported
c = static_cast<C*>(b);
// Invalid, but not reported, becuse unsafe
// and bruteforce.
c = (C*)b;
return 0;
}
So, casting between FdoIConnectionPropertyDictionary* and FdoRdbmsMySqlConnectionPropertyDictionary*
is like casting between B* and C* in the example above.
- Platform set to new value
PC
- Artifact Status set to new value
Unconfirmed
- Operating system set to new value
Linux
- Defect Severity set to new value
Critical
---------------------------------------------------------
This message was automatically generated by Project Tracker.
More information about the Fdo_issues
mailing list