This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: call of extra destructor
- To: dvv at dvv dot ru (Dima Volodin)
- Subject: Re: call of extra destructor
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 17 Mar 1999 15:13:15 -0300
- Cc: Alexander Zvyagin <zvyagin at mx dot ihep dot su>, egcs-bugs at egcs dot cygnus dot com
- References: <009D5438.365A0CF7.67@mx.ihep.su> <3709eebb.166213938@localhost>
On Mar 17, 1999, dvv@dvv.ru (Dima Volodin) wrote:
> On Wed, 17 Mar 1999 19:52:55 GMT+03:00, you wrote:
>> #include <stream.h>
>> class A { public: ~A (void) {cout << "D";} A (void) {cout << "C";} };
>> void f(A a) {}
>> int main(void) { { A a; f(a); } cout << endl; return 0; }
>> gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
>> $ g++ bug.c
>> $ a.out
>> CDDD
> The compiler creates an extra temp A object (which we all could
> easily live without), but it doesn't make its behavior incorrect.
But *why* is it creating such an extra temp A object? It can
certainly hurt performance, since it must be destructed, and I can't
see why it is being created in the first place. Calling f(A) needs a
single temporary, and the implicit copy constructor can't require an
additional temporary anyway...
--
Alexandre Oliva http://www.dcc.unicamp.br/~oliva aoliva@{acm.org,computer.org}
oliva@{dcc.unicamp.br,gnu.org,egcs.cygnus.com,samba.org}
Instituto de Computação, Universidade Estadual de Campinas, SP, Brasil
*** E-mail about software projects will be forwarded to mailing lists