By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,034 Members | 1,022 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,034 IT Pros & Developers. It's quick & easy.

HPUX Invalid Address Alignment when assigning double, casting to same type works?

P: n/a
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*, MyLessMyMap;

...

map.find(pAnotherStruct->dMyDouble); // Casting to a double here
corrects the error.
//Why?

Aug 11 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Jay Hamilton wrote:
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*, MyLessMyMap;

...

map.find(pAnotherStruct->dMyDouble); // Casting to a double here
corrects the error.
//Why?
I believe this is covered in the FAQ 5.8.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 11 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.