Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond!diamond From: diamond@diamond.csl.sony.junet (Norman Diamond) Newsgroups: comp.lang.c++ Subject: Re: ?-tion on sizeof classes Keywords: sizeof structure boundaries Message-ID: <10391@socslgw.csl.sony.JUNET> Date: 19 Jun 89 06:11:27 GMT References: <2425@blake.acs.washington.edu> Sender: news@csl.sony.JUNET Reply-To: diamond@csl.sony.junet (Norman Diamond) Organization: Sony Computer Science Laboratory Inc., Tokyo, Japan Lines: 29 In article <2425@blake.acs.washington.edu> keffer@ocean.washington.edu writes: >Aside from ..., is there any other reason why the size of an >object might not be the sum of its members? There can be hidden information, sometimes necessary for current features (e.g. vtable) or maybe for eventual assistance from friendly implementors (garbage collection, debugging, etc.). If you want (need) to know the size of a class, use "sizeof". That is the entire purpose of "sizeof". >The reason I ask is that it would sure be nice if I could assume > sizeof(Complex) == 2*sizeof(double) >because this is what a LOT of FORTRAN routines assume. FFT >routines, for example, routinely treat an N point complex vector as >a 2N real vector. A lot of FORTRAN routines make assumptions about C++ implementations? I'll bet C++ wasn't even a gleam in BS's eye when most of those FORTRAN programs were written. I'll bet that those FORTRAN programs conformed to the FORTRAN standard of their day though. When you write C++ programs, conform to C++ implementations and try to guess what existing practices (:-I irony) will eventually be standardized. -- Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.jp@relay.cs.net) The above opinions are claimed by your machine's init process (pid 1), after being disowned and orphaned. However, if you see this at Waterloo, Stanford, or Anterior, then their administrators must have approved of these opinions.