J
Jay Hamilton
Hello,
I am running into an invalid address alignment error on an HPUX box
when I attempt to lookup a value in a STL map. The argument being
passed in is a double, which is accessed from a structure; the map's
key is also a double. The issue seemed to be occuring in the map's
default comparison function so I implemented my own comparison
operator, but then the error continued happening in my new fxn.
Strangely, casting the double I pass in to a double seems to correct
the issue. This seems like a bad way to correct the problem, has
anyone dealt with a similar issue? I can get to the line of code in
the debugger that raises the error in the operator() fxn, and the left
and right variables both have correct values when I examine them.
struct MyLess : public binary_function<double, double, bool>
{
bool operator()(const double& left, const double& right) const
{
double dLeft(left);
double dRight(right); // Raises the error. right is valid tho-
return (dLeft < dRight);
}
};
typedef std::map<double, MyStruct*, MyLess> MyMap;
...
map.find(pAnotherStruct->dMyDouble); // Casting to a double here
corrects the error.
//Why?
I am running into an invalid address alignment error on an HPUX box
when I attempt to lookup a value in a STL map. The argument being
passed in is a double, which is accessed from a structure; the map's
key is also a double. The issue seemed to be occuring in the map's
default comparison function so I implemented my own comparison
operator, but then the error continued happening in my new fxn.
Strangely, casting the double I pass in to a double seems to correct
the issue. This seems like a bad way to correct the problem, has
anyone dealt with a similar issue? I can get to the line of code in
the debugger that raises the error in the operator() fxn, and the left
and right variables both have correct values when I examine them.
struct MyLess : public binary_function<double, double, bool>
{
bool operator()(const double& left, const double& right) const
{
double dLeft(left);
double dRight(right); // Raises the error. right is valid tho-
return (dLeft < dRight);
}
};
typedef std::map<double, MyStruct*, MyLess> MyMap;
...
map.find(pAnotherStruct->dMyDouble); // Casting to a double here
corrects the error.
//Why?