- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am working on application running on HPopenVMS/Itanium (IA-32).
I got doubt that if the compiler padded some bytes to make structure align on byte boundry, does that padded data is initialized? Does compiler padded garbage data into structure under the hood?
Can some one through some light on Alignment of stack variable vs Alignment of globacl or static variable.
TIA
Vineet.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes. It is IA-64. But our application is running on 32 bit mode.
Thanks,
Vineet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think Jennifer asked the question, because people sometimes get confused between IA64 (Itanium) linux and Intel64/AMD64 x86-64 linux, where 32-bit mode programs for the same operating system can run natively.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok. What is the Intel compiler alignment rule? If compiler is pedding bytes to make structure aligned to memory boundry, does these byte are un initialized?
Why I am asking is, I working on a symbol table, and every byte of that structure make hash table key. Now if those pedded bytes are not initialize, key to hash table will change and will give wrong fetch result.
I want to know what Intel compiler's alignment rule are? No VMS.
TIA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Alignment rules for Intel C compilers are compatible with the rules of the reference compilers which are prerequisites (Microsoft VC for Windows, gnu gcc/binutils for linux).Yourquestion seemed to be much more general than the question of padding within a struct.If you insist on writingcode which depends on details of the implementation, and may break for future versions of the reference compiler, you will have tostudy those detailsin more depth than could be described here.One would expect 32-bit VC to align data types of int or larger size to 4 byte boundaries, and 32-bit gcc to align 64-bit data types to 8 byte boundaries, subject tothe options which are available to change that behavior. If you are designing software, it seems ill-advised to make it depend on the current behavior of a particular compiler.
If you want to avoid undefined bytes within a structure, you might, for example, set up a union of an array of asimple data type such as int32_t (if you require assurance of exact 32-bit size) with whatever structure you require, and initialize the array. If your struct is assigned to allocated memory, you might use calloc() as a shortcut to initialize the entire region to int 0, but I'm no authority on the portability of it.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page