473,396 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
1 2841
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: | last post by:
When I execute the following (with an OleDBDataAdapter), wanting to add a row to a visual foxpro table: myrow= datasetTarget.Tables(0).NewRow 'fill all columns here like.. row(i)= myvalue '...
67
by: S.Tobias | last post by:
I would like to check if I understand the following excerpt correctly: 6.2.5#26 (Types): All pointers to structure types shall have the same representation and alignment requirements as each...
19
by: James Harris | last post by:
My K&R 2nd ed has in the Reference Manual appendix, A7.4.8 sizeof yields the number of BYTES required to store an object of the type of its operand. What happens if C is running on a machine that...
18
by: Peter Smithson | last post by:
Hi, I've read this page - http://devrsrc1.external.hp.com/STK/impacts/i634.html but don't understand it. Here's the text - "Non-standard usage of setjmp() and longjmp() could result in...
4
by: Romeo Colacitti | last post by:
I have a need to make a custom quasi-memory allocator, and I remembered a simple ons in K&R2. Looking at the code for it now, I think I notice a "fault" in the design, and I was wondering if...
7
by: Doug Bell | last post by:
Hi Does anyone know (or point me where I can find) how to set the alignment of a DataGrid Column Header different to the alignment of the column. I am trying to show some Right aligned columns...
10
by: haomiao | last post by:
I want to implement a common list that can cantain any type of data, so I declare the list as (briefly) --------------------------------------- struct list { int data_size; int node_num;...
3
by: ADS7328 | last post by:
Dear , My C++ program crashes with the following error: SIGNAL BUS (invalid addresses aligment) at random pleaces. t@1 (l@1) signal BUS (invalid address alignment) in...
12
by: Kevin | last post by:
Hey, I was hoping someone out here might be able to clue me in on some alignment issues I'm having. Hopefully I can explain this best through code below. ACSign and MyACSign functions below get...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.