This is the mail archive of the gcc@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: private static object construction bug?




--On Tuesday, August 06, 2002 08:51:28 AM +1000 Fergus Henderson <fjh@cs.mu.OZ.AU> wrote:

On 05-Aug-2002, Mark Mitchell <mark@codesourcery.com> wrote:

--On Monday, August 05, 2002 09:48:49 AM -0700 Joe Buck
<Joe.Buck@synopsys.com> wrote:

>
>> I entered a bug report on this (7458) that was promptly closed by
>> a Cygwin developer, but I believe incorrectly so, so I am posting
>> here.
>
> I've squashed the example a bit, but here it is:
>
> struct the_struct {
> 	int i;
> 	the_struct() { i = 0;}
> 	~the_struct() {	i = 1;}
> };
>
> void function() {
> 	static the_struct temporary;
> }
>
> The decision to close the bug report was correct.

Actually, I think it was only sort-of correct.

The ABI specifies functions a compiler can use to get thread safe
construction of local temporaries.
Did you mean to say "local statics"?
Yes.  My mailer crashed as I hit send -- I could see that typo but
I couldn't fix it. :-)

A slightly different code sequence could solve the double-construction
problem.
You guys are too smart.  I try to go up to ten thousand feet to get
the idea across and y'all want to pick apart the details. :-)

Ignore my pseudo-code; the point is that (in contrast to what Joe said),
the ABI does consider it a good idea for compilers to provide for
thread-safe constuction of local statics and gives routines to do that;
however, GCC doesn't currently use those routines.

--
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com


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