Article View: comp.std.c++
Article #3488Re: Initializer w/sizeof() on lhs term, okay or not?
From: J. Kanze
Date: Fri, 16 Feb 1996 17:19
Date: Fri, 16 Feb 1996 17:19
31 lines
2001 bytes
2001 bytes
In article <4fqq6l$qcr@venus.roc.csci.csc.com> tottinge@csci.csc.com
(Tim Ottinger) writes:
> It all comes down to a problem where a sizeof() is used on the rhs of an
> initialization, and it's operating on the object it's initializing:
>
> someType z = fred + sizeof(z);
> ^ ^^
This is perfectly legal. The object z is deamed to be known as soon as
the compiler encounters the `=' sign.
> Of course, I've changed the inherited code to read:
>
> someType z = fred + sizeof(someType);
>
> and all is well.
>
> So, is the compiler right on this one, that it's certainly disallowed, or is
> it merely eccentric?
Not even eccentric, really, and certainly legal.
--
James Kanze (+33) 88 14 49 00 email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils, itudes et rialisations en logiciel orienti objet --
-- A la recherche d'une activiti dans une region francophone
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is
in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
Technical Details
Message-ID:
<KANZE.96Feb16162731@gabi.gabi-soft.fr>Path:
arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austernReferences:
<4fqq6l$qcr@venus.roc.csci.csc.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austern From: kanze@gabi.gabi-soft.fr (J. Kanze) Newsgroups: comp.std.c++ Subject: Re: Initializer w/sizeof() on lhs term, okay or not? Date: 16 Feb 1996 09:19:05 PST Organization: GABI Software, Sarl. Approved: austern@isolde.mti.sgi.com Message-ID: <KANZE.96Feb16162731@gabi.gabi-soft.fr> References: <4fqq6l$qcr@venus.roc.csci.csc.com> NNTP-Posting-Host: isolde.mti.sgi.com X-Original-Date: 16 Feb 1996 15:27:31 GMT In-Reply-To: tottinge@csci.csc.com's message of 14 Feb 96 18:35:58 GMT X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBMSS9BUy4NqrwXLNJAQGbwgIAu8gU8jbWTndadKp5z0fyMEIOE1FqsiO9 ZummP6pEcjtNw+JS9xit8ajQ0YcGseWVpY94i9Y+457O+54pYEjmfA== =df+Y Originator: austern@isolde.mti.sgi.com