From 7445344738245540473
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,a4f3c15d97de4122
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2002-07-14 10:24:03 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!kibo.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: Gennaro Prota <gennaro_prota@yahoo.com>
Newsgroups: comp.std.c++
Subject: Re: Why don't constructors and destructors have return types?
Date: Sun, 14 Jul 2002 17:22:51 GMT
Organization: [Infostrada]
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <eo23jus5gh0a6or1p97hmnp3d7l78c9ii2@4ax.com>
References: <3d209e70.1346875@news.earthlink.net> <VcmwzfCb6YI9EwOi@robinton.demon.co.uk> <3d21c520.27573671@news.earthlink.net> <nhu5iuocqmnu3jf3h2k65ic17euk894v9j@4ax.com> <3d24ccd3.20691953@news.earthlink.net> <7uvaiug6ionjvtmhp8lks5k8s9qvdo12i5@4ax.com> <3d25e7c0.34024125@news.earthlink.net> <qn6oiuojq5ogmdegpvt3jt5bl85sd4erbc@4ax.com> <3d2c4170.15685078@207.217.77.25> <k4eriugdf99ibvvljv86t8f367iv89n4ln@4ax.com> <23b84d65.0207121402.452015f@posting.google.com>
X-Trace: mail2news.demon.co.uk 1026667389 mail2news:24270 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Newsreader: Forte Agent 1.9/32.560
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Date: Sun, 14 Jul 2002 17:59:13 MET DST
Lines: 86
Xref: archiver1.google.com comp.std.c++:12695

On 14 Jul 2002 01:51:10 GMT, Allan_W@my-dejanews.com (Allan W) wrote:

>
>Gennaro Prota <gennaro_prota@yahoo.com> wrote
> > b) Changing 5.3.3p1 to explicitly state that sizeof considers
> > exclusively "complete objects"
> >

First of all I want to clarify that

a) this (not submitted) DR is based on the assumption that the type of
base sub-objects is the type of the corresponding base class.

For instance in

class D : public B { };

I assume the D has a sub-object of type B. As the discussions on
comp.lang.c++.moderated have pointed out it's unlikely that this is
the correct way of looking at it.


What I'd like to know, and is one of the reasons why I switched to
comp.std.c++, is whether these sorts of issues were examined by the
committee and therefore taken into account when deciding the wording
of fundamental parts of the standard. 



b) My descriptions of the DR are a little misleading. If you look at
the proposed resolution only, you will see that I say that sizeof(T)
gives the size of a complete object of type T. I do not say that
objects that are not complete (like data members) cannot have the same
size.


> > "The sizeof operator yields the number of bytes in the object
> > representation of [its operand -> *a complete object* whose type is
> > determined by its operand]."
>
>This might be feasible for objects that already have type_info.
>But it's a fundamental change, and shouldn't be taken lightly.
>
>     class base { char x[4]; };
>     void foo(base *b) {
>         std::cout << sizeof(base) << "-" << sizeof(*b);
>     }
>
>     class der : public base { char y[2]; };
>     int main() {
>         Base b; foo(&b); std::cout << ", ";
>         Der  d; foo(&d); std::cout << std::endl;
>     }
>
>What does this print? Under current rules, it prints "4-4, 4-4" unless
>alignment concerns make base bigger than 4 bytes. Under new rules
>it could be "4-4, 4-6" or "4-4, 4-8". Furthermore, sizeof() can no
>longer be performed at runtime except in constrained situation, such as
>   sizeof(base)
>in the code above.

My intent was the change to 5.3.3/1 to be editorial in the sense that
it only affected the wording. No well-defined program should be
affected by the change because it doesn't concern the type you go
considering: in your example sizeof (*b) would be the size of a
complete object (as it is now) and the type of that object would still
be the -static- type of the expression *base.


***
 Anyhow, please, don't formalize on the DR in se (what if base is
abstract? :-)). Consider it a rough sketch. Let's think instead if we
can consider the base sub-object of der to be of type base or not.
That's the real question.

***


Genny.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



