[Rose-public] Size of types

Scott Warren scott at rice.edu
Mon Sep 9 13:41:19 PDT 2013


Greg,

Sizes of types are implementation-dependent in both C and C++. The language standards provide only weak partial specifications for this and in practice the sizes of types do vary from system to system. Factors influencing the size of a type are processor architecture, compiler vendor and version, and command-line arguments to the compiler. Sources of variability include:

	(1) sizes of integral types and pointers (affected by OS, compiler, and command line options)

	(2) alignment requirements (affected by processor architecture, compiler, and command line options)

	(3) representation of bit fields (affected by compiler and command line options)

Note that because of (2) and (3) the size of a class, structure, or array type is implementation-dependent even if one restricts integral types to explicitly-sized types such as 'int32'. Again, non-portability of type sizes is not theoretical but a practical issue in software development.

Thus to compute sizes of types correctly, a ROSE translator would have to incorporate knowledge of the relevant behavior of the OS's, architectures, compilers, and compiler versions of interest, and the user would have to tell the translator which OS, architecture, compiler and version, and command line options he is using.

skw 


On Sep 9, 2013, at 2:08 PM, "Bronevetsky, Greg" <bronevetsky1 at llnl.gov> wrote:

> Leo, since nobody has replied to my question, I’ll go ahead and write this myself. However, I’m having trouble navigating the structure of class, struct and array declarations. Do you have time this afternoon to answer a few questions I have?
>  
> Greg Bronevetsky
> Lawrence Livermore National Lab
> (925) 424-5756
> bronevetsky at llnl.gov
> http://greg.bronevetsky.com
>  
> From: rose-public-bounces at nersc.gov [mailto:rose-public-bounces at nersc.gov] On Behalf Of Bronevetsky, Greg
> Sent: Friday, September 06, 2013 6:09 PM
> To: Quinlan, Dan
> Cc: 'rose-public at nersc.gov'
> Subject: Re: [Rose-public] Size of types
>  
> No, I mean the size of the C/Fortran/Java type the SgType denotes. 
> -Greg Bronevetsky 
> (sent from my phone; apologies for typos and terseness)
>  
> From: Quinlan, Dan 
> Sent: Friday, September 06, 2013 06:00 PM
> To: Bronevetsky, Greg 
> Cc: rose-public at nersc.gov <rose-public at nersc.gov> 
> Subject: Re: [Rose-public] Size of types 
>  
> Hi Greg,
>     Perhaps I don't understand, but why is "sizeof(SgType)" not the answer?
>  
> Thanks,
> Dan
>  
> From: <Bronevetsky>, Greg Bronevetsky <bronevetsky1 at llnl.gov>
> Date: Friday, September 6, 2013 4:43 PM
> To: "rose-public at nersc.gov" <rose-public at nersc.gov>
> Subject: [Rose-public] Size of types
>  
> I need to know the number of bytes that a given SgType takes up, much like the size_of() operator in C. Is there already functionality in ROSE to do something like this?
>  
> Greg Bronevetsky
> Lawrence Livermore National Lab
> (925) 424-5756
> bronevetsky at llnl.gov
> http://greg.bronevetsky.com
>  
> !DSPAM:3697,522e1cec70151523321172! _______________________________________________
> rose-public mailing list
> rose-public at nersc.gov
> 
> 
> !DSPAM:3697,522e1cec70151523321172!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nersc.gov/pipermail/rose-public/attachments/20130909/4f72eafb/attachment.html>


More information about the rose-public mailing list