c++/9075: Destructor is called more times than required..
Andrew Pinski
pinskia@physics.uc.edu
Fri Dec 27 20:26:00 GMT 2002
The following reply was made to PR c++/9075; it has been noted by GNATS.
From: Andrew Pinski <pinskia@physics.uc.edu>
To: sunil.k.davasam@intel.com
Cc: Andrew Pinski <pinskia@physics.uc.edu>, gcc-gnats@gcc.gnu.org
Subject: Re: c++/9075: Destructor is called more times than required..
Date: Fri, 27 Dec 2002 23:16:07 -0500
This is not a bug because func's c is not a reference to a variable but
a variable that is copied.
If you want a function that does not copy, then use a `&' and then the
destructor is not called twice, only once.
Read a C++ book for more information about pass by value, not reference.
Thanks,
Andrew Pinski
On Friday, Dec 27, 2002, at 22:46 US/Eastern, sunil.k.davasam@intel.com
wrote:
>
> void func(C c)
> {
> printf("func()\n");
> }
>
> int main(void)
> {
> C c;
>
> func(c);
> printf("main()\n");
> return 0;
> }
>
More information about the Gcc-prs
mailing list