Article View: comp.std.c++
Article #1880Re: What is sizeof(T&) ??
From: Tony Cook
Date: Fri, 01 Sep 1995 03:29
Date: Fri, 01 Sep 1995 03:29
26 lines
1445 bytes
1445 bytes
J. Kanze (kanze@gabi-soft.fr) wrote:
: (Concerning the last, consider the following:
: struct X { int i ; char c ; } ;
: X x ;
: char c[ 3 ] ;
: On my system, sizeof( X ) == 8, as does sizeof( x ). And of course,
: sizeof( c ) == 3. Curiously, however, the two variables only take up a
: total of 8 bytes; in this particular case, the physical sizeof x is 5,
: and not 8. This is a perfectly legal, and frequent, implementation.)
Are you sure about this? Considering X is a POD, what if the
programmer has coded:
memset(&x, 0, sizeof(X));
somewhere in their program? Or does this produce undefined
behaviour?
--
Tony Cook - tony@online.tmx.com.au
100237.3425@compuserve.com
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<DE7Czw.4ps@online.tmx.com.au>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageReferences:
<199508290413.VAA02818@corvette.ucr.edu> <41v7eh$2b1@gabi.gabi-soft.fr>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: tony@online.tmx.com.au (Tony Cook) Newsgroups: comp.std.c++ Subject: Re: What is sizeof(T&) ?? Date: 1 Sep 1995 03:29:48 GMT Organization: Home Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <DE7Czw.4ps@online.tmx.com.au> References: <199508290413.VAA02818@corvette.ucr.edu> <41v7eh$2b1@gabi.gabi-soft.fr> NNTP-Posting-Host: taumet.eng.sun.com X-Newsreader: TIN [version 1.2 PL2] Originator: clamage@taumet