🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2742

Re: an optimization I claim is illegal

#2742
From: Dick Menninger
Date: Tue, 28 Nov 1995 00:09
36 lines
2041 bytes
> ==========Fergus Henderson, 11/21/95==========
 
> If you changed the line
 
>        D1 d1 (7);
 
> to
 
>      D1 &d1 = *(D1 *) malloc(sizeof(D1) + sizeof(D2));
>      new (&d1) D1 (7);
 
> then the storage would be definitely large enough to hold either
> a D1 or a D2 and would be correctly aligned to hold any object,
> so this problem wouldn't arise.

Although it would be overkill as far as allocating
enough storage, how this insures correct alignment
less clear, at least to me.  Is there a constraint on
where in an object image the "this" pointer points?
Or is it that the low address of a memory block
is supposed to be passed when this form of new
is used (my memory is fuzzy on this)?  I had the
impression that the "this" pointer could have an
environment specific (or even variable between classes)
relationship to the object instance.  Certainly some
hardware architectures would favor a centrist "this"
pointer for some sizes of objects (small signed offsets
imbedded in instructions dereferencing "this").

Good Day
Dick
Dick.Menninger@DaytonOH.ATTGIS.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: <DIpMqo.Coz@falcon.daytonoh.attgis.com>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
References: <9532614.29353@mulga.cs.mu.OZ.AU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 28 Nov 95 00:09:51 GMT
Approved: fjh@cs.mu.oz.au
Newsgroups: comp.std.c++
From: Dick Menninger <Dick.Menninger@daytonoh.attgis.com>
Subject: Re: an optimization I claim is illegal
Message-ID: <DIpMqo.Coz@falcon.daytonoh.attgis.com>
Reply-To: mennid <Dick.Menninger@daytonoh.attgis.com>
Organization: AT&T Global Information Solutions
X-Newsreader: DiscussIT 2.5.1.3 for MS Windows [AT&T Software Products Division]
References: <9532614.29353@mulga.cs.mu.OZ.AU>
X-Original-Date: Mon, 27 Nov 1995 16:20:48 GMT
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMLpTY+EDnX0m9pzZAQHkPAF/bnD6ztdspvQMoOtwgMRIXXt+IqoKJBCv
 nK6zuhxG3exHdkLzz8frivLhCejwqiVX
 =qs3K