RE : Apparent thread-safety bug in Glib 2.0 docs



Sebastion wrote:
> 
> Hi Christopher,
> 
> > 
> http://developer.gnome.org/doc/API/2.0/glib/glib-Threads.html#id294168
> > 2
> > 
> > It lists 4 examples while talking about thread-safe code. 
> > Unfortunately, the 3rd & 4th examples, though labeled as 
> thread safe 
> > appear to not be thread safe.
> > 
> > The problem that I'm perceiving is that the 
> "current_number" variable 
> > is not declared as volatile. While this might seem nit 
> picky, without 
> > this flag the compiler may very well generate incorrect code. Given 
> > that this is a common programmer error, I think it'd be a 
> good idea to 
> > either elaborate this point in the documentation, or at 
> least correct 
> > the examples. Thoughts?
> 
> You are right. This is an oversight. I'll propose adding the 

Hi all,

Can you please elaborate a bit more how is a compiler suppossed to
generate incorrect code in examples 3 & 4?
They look perfectly fine to me.

Cheers,




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]