473,498 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Data Alignment.

Hi,
To make data aligned to memory boundry, compiler pedded some byte. I
wanted to know if these bytes are initialized? or compiler pedded some
un initialized byte.

Thanks,
Sep 22 '08 #1
5 1665
On Sep 22, 11:02 am, vineet <vinsha...@gmail.comwrote:
Hi,
To make data aligned to memory boundry, compiler pedded some byte. I
wanted to know if these bytes are initialized? or compiler pedded some
un initialized byte.

Thanks,
The padding, if any, is not initialized.
In fact neither is the data unless you have done so.
The question is: why would that matter?
Your code should be completely transparent to padding, regardless of
platform.
Sep 22 '08 #2
On Sep 22, 4:02*pm, vineet <vinsha...@gmail.comwrote:
Hi,
To make data aligned to memory boundry, compiler pedded some byte. I
wanted to know if these bytes are initialized? or compiler pedded some
un initialized byte.

Thanks,
I think it is depends upon which part of the memory data sits - stack,
heap, initialized DS, Uninitialized DS
- nOby jOse
Sep 22 '08 #3
no*****@gmail.com wrote:
On Sep 22, 4:02 pm, vineet <vinsha...@gmail.comwrote:
>Hi,
To make data aligned to memory boundry, compiler pedded some byte. I
wanted to know if these bytes are initialized? or compiler pedded some
un initialized byte.

Thanks,

I think it is depends upon which part of the memory data sits - stack,
heap, initialized DS, Uninitialized DS
- nOby jOse
Also some compilers (e.g. intel) has compiler flags such as
'-no-bss-init' to allow finer control of memory initialization. Really,
the answer is platform-compiler dependent and has not much to do with C++.
Sep 22 '08 #4
On Sep 22, 4:37*pm, Salt_Peter <pj_h...@yahoo.comwrote:
On Sep 22, 11:02 am, vineet <vinsha...@gmail.comwrote:
Hi,
To make data aligned to memory boundry, compiler pedded some byte. I
wanted to know if these bytes are initialized? or compiler pedded some
un initialized byte.
Thanks,

The padding, if any, is not initialized.
In fact neither is the data unless you have done so.
Unless it is POD with static storage duration, in which case it is
guaranteed to be zero-initialised.

--
Max
Sep 23 '08 #5
On Sep 23, 11:00 am, Maxim Yegorushkin <maxim.yegorush...@gmail.com>
wrote:
On Sep 22, 4:37 pm, Salt_Peter <pj_h...@yahoo.comwrote:
On Sep 22, 11:02 am, vineet <vinsha...@gmail.comwrote:
To make data aligned to memory boundry, compiler pedded
some byte. I wanted to know if these bytes are
initialized? or compiler pedded some un initialized byte.
The padding, if any, is not initialized.
In fact neither is the data unless you have done so.
Unless it is POD with static storage duration, in which case
it is guaranteed to be zero-initialised.
The members, for types where zero initialization makes sense
(not references, for example). And this is guaranteed to occur
even within types with constructors, etc.; zero initialization
takes place before any dynamic initialization. But the original
question concerned padding, and that's not guaranteed (for the
obvious reason that what is meant by zero initialization depends
on the type, and padding has no type).

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Sep 23 '08 #6

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

Similar topics

6
23553
by: Sebastian Kemi | last post by:
How should a write a class to a file? Would this example work: object *myobject = 0; tfile.write(reinterpret_cast<char *>(myobject), sizeof(*object)); / sebek
9
2395
by: cppaddict | last post by:
Let's say you want to implement a Dictionary class, which contains a vector of DictionaryEntry. Assume each DictionaryEntry has two members, a word and a definition. Now assume your program...
4
3828
by: Thomas Paul Diffenbach | last post by:
Can anyone point me to an open source library of /statically allocated/ data structures? I'm writing some code that would benefit from trees, preferably self balancing, but on an embedded system...
67
10649
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...
13
2966
by: aegis | last post by:
The following was mentioned by Eric Sosman from http://groups.google.com/group/comp.lang.c/msg/b696b28f59b9dac4?dmode=source "The alignment requirement for any type T must be a divisor of...
2
1592
by: tat | last post by:
Dear C++ experts, I have a piece of code (see below). Alignment object has a data member that is a vector of Sequence objects. Sequence object, in turn, has a data member that is a vector of...
5
575
by: pt | last post by:
Hi, i am wonderng what is faster according to accessing speed to read these data structure from the disk in c/c++ including alignment handling if we access it on little endian system 32 bits...
31
7699
by: aarklon | last post by:
Hi all, this is a question which i saw in a book typedef struct mall_li_header_ { int refcnt; uchar pool; uchar flag; ushort magic_no; char data;
1
1944
by: Stephen Plotnick | last post by:
I have a checkbox in a data grid that does not change it's state until I actually leave the field. I've done this routine several times in other data grids without an issue. I'm using VB.2003. ...
6
2399
by: Wesley Peace | last post by:
I hate to cross post, but I've gotten no answer yet on a problem I'm having with visual studio 2008. I've created a series of forms with controls to access a Access database tables. The...
0
7125
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
7165
Oralloy
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,...
1
6885
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...
0
5462
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 project—planning, coding, testing,...
1
4908
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...
0
4588
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...
0
3081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1417
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 ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.