473,385 Members | 1,730 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,385 software developers and data experts.

cast odd boundary?

Hi

I have read somwhere that this problem is handled by the
Intel cpu's (firmware), but what will happen on other types of cpu's.

struct
{
char aa; // even boundary 0xaa00
char bb[4]; // assume on odd boundary 0xaa01
} mstr;

long ll;
ll = *((long*)mstr.bb); // no: 1 do i get an exception?

*((long*)mstr.bb) = ll; // no: 2 do i get an exception?

/dev

Nov 14 '05 #1
1 1426
In article <40********@news1e1.seinf.abb.se>,
"Devrobcom" <de*******@hotmail.com> wrote:
Hi

I have read somwhere that this problem is handled by the
Intel cpu's (firmware), but what will happen on other types of cpu's.

struct
{
char aa; // even boundary 0xaa00
char bb[4]; // assume on odd boundary 0xaa01
} mstr;
Assuming that that is the case (i.e. there is no padding between aa
and bb, and sizeof(long) == 4).

long ll;
ll = *((long*)mstr.bb); // no: 1 do i get an exception?
You could get an exception, or you app could simply crash, or monkeys
could spring forth from your gut :), as that is undefined behavior. Many
platforms require special alignment for particular types.
*((long*)mstr.bb) = ll; // no: 2 do i get an exception?


Same answer

Nov 14 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Daniele Varrazzo | last post by:
Hi everybody, i'm experiencing crashing of the apache process when a mod_python handler access the properties "boundary" and "allowed_xmethods" of the request argument. This prevents the use of...
14
by: Singleton | last post by:
Can some one guide me what is word boundary? google is no good for me for this thanks in advance
11
by: Taran | last post by:
Hi all, I was wondering how does address alignment to x byte boundary is done. For example, if I say "adjust the requested size to be on a 4-byte boundary" or for that matter 8 byte boundary....
2
by: szabi | last post by:
Hi! I have seen in a couple of libraries that object are never passed through dll boundary, instead the results are returned through an output parameter reference like: void f(std::string &s)...
3
by: Tao | last post by:
hi. guys, I have two AppDomains, AppDomain0 and AppDomain1. In AppDomain1, I got a class implements an interface IInterface0. In AppDomain0, I also define a IInterface0, the code of two...
29
by: K. Jennings | last post by:
I would like to get the result of malloc() such that it is aligned on a given boundary - 8, in this case. Assuming that sizeof(u64) is 8, will u64 *p = malloc(N) ; do the trick in general? ...
3
by: Boki | last post by:
Hi All, I saw my code jump out the function call directly without throw a boundary error.... no boundary check ? string str_member_id = new string;
2
by: kgeorge2 | last post by:
A library which i use, has an array class class LibArray { public: LibArray():_array(NULL),_len(0); LibArray(int n, float val):_array( new float),_len(n){} /** more complete definition...
6
by: Gernot Frisch | last post by:
Hi, the program below workes w/o problems on a GP2X and on the PC, but my PocketPC (using GCC 3.3.3) crashes. Very dissapointing, since I expect some speed boost from it. Thnak you for your...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.