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()(cons t 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(pAnoth erStruct->dMyDouble); // Casting to a double here
corrects the error.
//Why? 1 2862
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()(cons t 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(pAnoth erStruct->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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
' then
datasetTarget.Tables(0).Rows.Add(myrow)
dataAdapterTarget.Update(datasetTarget.Tables(0)) '*
|
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 other. All pointers to union types shall
have the same representation and alignment requirements as each other.
Does it mean that *all* structure (or union) types have the same
alignment?
Eg. type
|
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 addresses larger words only?
Shouldn't sizeof be defined to return the smallest number of 'storage
units' required to store an object of the type of its operand?
As a general point, is there a guide to what aspects of C would fail if run
on a...
|
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
compatibility problems. The contents of the jmp_buf buffer are specific
|
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 people would back me up
on this.
The design basically uses a pool of memory, allocated as a character
array. Pointers into the array are retured by the allocated function.
Isn't this very dangerous, as a char has very lenient memory alignment...
| |
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 and the header looks wrong
squashed to the right. If I could even add a trailing space but it trims any
trailing spaces off.
Thanks
|
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;
char nodes; //will be list_node1,list_node2...
};
|
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
__rwstd::digit_writer<char,std::ostreambuf_iterator
|
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 compiled
(gcc) into one library, where as the code that executes these
functions gets compiled into a seperate library. Calls to MyACSign
work fine, calls to the straight ACSign do not and I believe it is due
to alignment issues, but I can't...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |