Newsgroups: comp.lang.c++ Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!batcomputer!theory.tn.cornell.edu!lijewski From: lijewski@theory.tn.cornell.edu (Mike Lijewski) Subject: Re: The "new" Operator and the Copy Constructor Message-ID: <1991Mar29.024933.21277@batcomputer.tn.cornell.edu> Sender: news@batcomputer.tn.cornell.edu Nntp-Posting-Host: theory.tn.cornell.edu Organization: Cornell National Supercomputer Facility References: <1991Mar27.233549.1487@jpl-devvax.jpl.nasa.gov> <643@taumet.com> Date: Fri, 29 Mar 1991 02:49:33 GMT In article <643@taumet.com> steve@taumet.com (Stephen Clamage) writes: >seq@jpl-devvax.jpl.nasa.gov (Sequence Folks) writes: > >|1) The compiler complains when I try to create an object from the heap >|using the default copy constructor. >| class D {}; >| D d; >| D* pd; >| pd = new D(d); > >This is a compiler bug. The code should work, and does on other >compilers I tried. I don't quite agree with Stephen here. Why should this work? Nowhere in the ARM can I find any indication that one is allowed to explicitly call a default copy constructor. Granted, it also isn't explicitly disallowed, but considering all the examples and commentary, what is one to think? There is even a sentence in the commentary which states that the default assignment operator needn't be generated unless it's address is taken, which is analogous to the default copy constructor situation. My reading is basically that if a situation calls for a copy constructor, the compiler will do the "right thing". Am I reading something into this that isn't there, or could this be something that was intentionally left vague and up to the compiler implementer? >-- > >Steve Clamage, TauMetric Corp, steve@taumet.com -- Mike Lijewski (H)607/272-0238 (W)607/254-8686 Cornell National Supercomputer Facility ARPA: mjlx@eagle.cnsf.cornell.edu BITNET: mjlx@cornellf.bitnet SMAIL: 25 Renwick Heights Road, Ithaca, NY 14850