This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/9075: Destructor is called more times than required..
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: nobody at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 28 Dec 2002 04:26:01 -0000
- Subject: Re: c++/9075: Destructor is called more times than required..
- Reply-to: Andrew Pinski <pinskia at physics dot uc dot edu>
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;
> }
>