473,804 Members | 4,223 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what is word boundary?

Can some one guide me what is word boundary?
google is no good for me for this
thanks in advance
Sep 17 '05
14 19188
On Sun, 18 Sep 2005 00:42:33 +0100, "Singleton"
<ku*****@homeca ll.co.uk> wrote in comp.lang.c++:
I just took c++ exam in brainbnch . one of the question is
Q:)According to the C++ standard, what is an object's internal
representation in memory guaranteed to be?
Choice 1 : Contiguous
Choice 2 : On the stack
Choice 3 : Initialized
Choice 4 : On a word boundary
Choice 5 : On the heap


None of these answers is correct according to the C++ standard. And
C++, as I said, does not even define the term "word boundary". This
merely means that Brainbench has made a mistake in their test. In the
past, they have worked to correct such errors when pointed out to
them. I do not know whether they still do so or not.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Sep 18 '05 #11
On 17 Sep 2005 18:26:25 -0700, "Greg" <gr****@pacbell .net> wrote in
comp.lang.c++:
Singleton wrote:
Can some one guide me what is word boundary?
google is no good for me for this
thanks in advance


The size of an int in a C++ compiler should be the same as the size of
a word for the architecture that that compiler targets.


Yes, that is a an intention expressed by the C language standard, and
inherited by C++. But there are C and even some C++ compilers for
architectures that are strictly 8-bit, and have no 16-bit registers at
all, yet here int must still be at least 16 bits.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Sep 18 '05 #12
Andrew Koenig wrote:
"Singleton" <ku*****@homeca ll.co.uk> wrote in message
news:43******** **@mk-nntp-2.news.uk.tisca li.com...
I just took c++ exam in brainbnch . one of the question is

Q:)According to the C++ standard, what is an object's internal
representation in memory guaranteed to be?
Choice 1 : Contiguous


Objects with virtual base classes are not always contiguous,
which rules out (1).


The C++ standard requires that the memory for arrays (and vectors)
must be contiguous. This seems to imply that the objects stored
in the array or vector must also use contiguous memory.

What's your definition of 'contiguous' ?

Sep 18 '05 #13
The word boundary refers to word level aligment in memory. If the word
is 32 bit, it means that words are aligned at addresses that are
divisible by 4.

The following article should help:
http://www.eventhelix.com/RealtimeMa...ndOrdering.htm

--
EventStudio 2.5 - http://www.EventHelix.com/EventStudio
Sequence Diagram Based System Design and Modeling Tool

Sep 19 '05 #14
"Old Wolf" <ol*****@inspir e.net.nz> wrote in message
news:11******** ************@g1 4g2000cwa.googl egroups.com...
Objects with virtual base classes are not always contiguous,
which rules out (1).
The C++ standard requires that the memory for arrays (and vectors)
must be contiguous. This seems to imply that the objects stored
in the array or vector must also use contiguous memory. What's your definition of 'contiguous' ?


Good question. Consider this:

struct A { int a; };
struct B : public virtual A { int b; };
struct C : public virtual A { int c; };
struct D: public virtual B, public virtual C { ind d; };

D d;
B* bp = &d;
C* cp = &d;

Now bp points to an object of type B and cp points to an object of type C.
Each of these objects has a member named a, and because both objects are
subobjects of the same object (namely d), bp->a and cp->a are the same
object. In other words, &bp->a == &cp->a.

The pointer bp points to an object (*bp) of type B, which has two members: b
(defined directly as part of the type) and a (inherited from the base class
A). I think that at the very least, if you say that *bp is contiguous, you
are saying that no other objects appear between bp->a and bp->b. They might
not occupy adjacent addresses, but there can't be any other objects between
them.

Therefore, if *bp is contiguous, bp->a and bp->b are in adjacent memory with
the possible exception of padding or other compiler-generated bookkeeping.

So is *bp contiguous? Well, the answer is either yes or no. If it's no,
then there is such a thing as a discontiguous object. So let's assume that
the answer is yes and forge on. This yes answer implies that bp->a and
bp->b have no other objects between them.

Now let's look at *cp, the object to which cp points. It has two members,
cp->a and cp->c. Is *cp contiguous?

If *cp is contiguous, cp->a and cp->c must have no other objects between
them. However, cp->a is the same object as bp->a, and we have already
established that there is an object (namely bp->b) adjacent to bp->a.
Therefore cp->c cannot be adjacent to cp->a, and *cp cannot be contiguous!

In other words, I have proven that after executing the code shown above, it
is impossible for bp and cp both to point to contiguous objects, according
to a fairly loose definition of contiguity.

Sep 19 '05 #15

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

Similar topics

86
7809
by: Michael Kalina | last post by:
Because when I asked for comments on my site-design (Remember? My site, your opinion!) some of you told me never to change anything on font-sizes! What do you guys think of that: http://www.clagnut.com/blog/348/ I hope that's going to be a good discussion! Michael
11
8910
by: L. Chen | last post by:
The standard says that a char* or void* pointer has the least strict alignment. But I do not know what is a strict alignment. What does that mean?
13
19367
by: Vijay Kumar R. Zanvar | last post by:
Hello, I have few questions. They are: 1. Is "const char * const *p;" a valid construct? 2. How do I align a given structure, say, at 32-byte boundary? 3. Then, how do I assert that a given object is aligned, say, at 32-byte boundary?
3
2404
by: Muhammad Farooq-i-Azam | last post by:
Hi, I am trying to define an arp structure but having problem doing so. I think I have define the correct arp structure but I find myself in a strange problem. The size of structure that I have defined is 28 bytes, but it is reported to be 32 bytes by the sizeof() call. Interestingly, sum of individuals members of the sturcture is 28. However, the sizeof() the entire structure is returned to be 32.
10
8943
by: Aj Blosser | last post by:
Hey guys, I have a question for you, I have a setup where I'm sending files through the POST to a php web page, I read the file contents, put that file contents as text into the POST string, and send it on it's way. it works perfectly for text files. However, I can't open a word document like a text file and have it give me the result I need. I'm looking for a way to just open a word document and get all the values in it like you would...
669
26262
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
2
2191
by: David | last post by:
Hi, Could PHP be used to take a txt file (or set of txt files) and add a string of characters every X number of words or characters? Say a txt file with 50,000 characters/5,000 words how would you go about adding a string of characters every 5,000 characters or 500 words. To improve on this I'd want to if using characters as the guide to use
6
9669
by: Gary Bond | last post by:
Hi All, Being a bit of a newbie with regex, I am confused when using word boundaries. For instance, I want to replace all the stand alone '.5k' that occur in an input string, with 500. In other words "this is a .5k example" goes to "this is a 500 example" The replace should not touch '.5k' that occurs inside a word. For example:
8
2291
by: Avi | last post by:
Hi all, I'm using string Replace(string oldValue, string newValue) and would like it to replace only full words that matches oldValue and not when oldValue is a substring of a larger word. How can it be done? Thanks, Avi
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9579
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,...
0
10332
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10320
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,...
0
9150
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7620
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6853
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();...
0
5521
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4299
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.