Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Data Alignment.

Reply
Thread Tools

Data Alignment.

 
 
vineet
Guest
Posts: n/a
 
      09-22-2008
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,
 
Reply With Quote
 
 
 
 
Salt_Peter
Guest
Posts: n/a
 
      09-22-2008
On Sep 22, 11:02 am, vineet <vinsha...@gmail.com> wrote:
> 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.
 
Reply With Quote
 
 
 
 
nobyjos@gmail.com
Guest
Posts: n/a
 
      09-22-2008
On Sep 22, 4:02*pm, vineet <vinsha...@gmail.com> wrote:
> 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
 
Reply With Quote
 
Fei Liu
Guest
Posts: n/a
 
      09-22-2008
wrote:
> On Sep 22, 4:02 pm, vineet <vinsha...@gmail.com> wrote:
>> 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++.
 
Reply With Quote
 
Maxim Yegorushkin
Guest
Posts: n/a
 
      09-23-2008
On Sep 22, 4:37*pm, Salt_Peter <pj_h...@yahoo.com> wrote:
> On Sep 22, 11:02 am, vineet <vinsha...@gmail.com> wrote:
>
> > 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
 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      09-23-2008
On Sep 23, 11:00 am, Maxim Yegorushkin <maxim.yegorush...@gmail.com>
wrote:
> On Sep 22, 4:37 pm, Salt_Peter <pj_h...@yahoo.com> wrote:


> > On Sep 22, 11:02 am, vineet <vinsha...@gmail.com> wrote:


> > > 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:
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
simple programs to deal with data format, data synchronisation Ram VHDL 1 02-24-2005 05:34 PM
Data Recovery SOURCE CODE ( SOURCE CODES of Professional Data Recovery Software ) Author Tarun Tyagi Cisco 0 12-29-2004 05:03 PM
Data Recovery Book and Online Business Promotion, Products Sales Promotion, Search Engine Optimization and Online Data Recovery Training services Author Tarun Tyagi Cisco 0 12-15-2004 01:52 AM
Data type question for OLEdb data types Brian Henry ASP .Net 1 10-05-2003 03:18 PM
Bind different rows to different data sources in data grid AD ASP .Net 1 08-23-2003 10:34 PM



Advertisments