Static variable being constructed twice.

  • Thread starter Thread starter Jon
  • Start date Start date
J

Jon

I am using the following code in a header, in a mixed C++ program:

class C {
public:
C& I() {
static C c;
return c;
}
};

The internal Boolean that indicates that c has been constructed is at a different locations depending on if it is call from a unit
with or without the /clr option.. Of course this causes c to be constructed twice.
 
Hi Jon,
The internal Boolean that indicates that c has been constructed is at a
different locations depending on if it is call from a unit
with or without the /clr option.. Of course this causes c to be
constructed twice.

Would you please provide some more code(such as the internal Boolean and
the calling code) about this issue?

It appears I couldn't repro the third constructing of the Class C(the first
for the C c1; the second for the c1.I(); ) whatever compiling the calling
code source file with or without the /clr option.


Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
Unfortunately, I did not save the offending code.
Hard as I try, I can not reproduce the error.
So at this point. it looks like pilot error.
 
Back
Top