This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c++/9075: Destructor is called more times than required..


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;
 > }
 >
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]