Actions
| Post | |
| Subscribe | |
| Unsubscribe |
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [c++-pthreads] Initialization of local static mutex
- To: Mark Mitchell <mark@xxxxxxxxxxxxxxxx>
- Subject: Re: [c++-pthreads] Initialization of local static mutex
- From: Roland Schwarz <roland.schwarz@xxxxxxxxx>
- Date: Sun, 08 Oct 2006 19:19:36 +0200
Mark Mitchell wrote:
A standard-conforming compiler, used with a standard-conforming POSIX library, cannot suffer from a race condition in the code that you posted because PTHREAD_MUTEX_INITIALIZER must be a constant-expression.
Sorry for keep on bugging, but did you read my citation from the standard: 6.7/4: "The zero-initialization of all local objects with static storage duration is performed before any other initialization takes place. A local object of POD type with static storage duration initialized with constant-expressions is initialized before its block is first entered. ..." Does this mean, the compiler is allowed to emit code to initialize the mutex variable at runtime, after "any other initializations have taken place" and before "block is entered"? A compiler is still conforming in this case, while at the same time susceptible to the race. We do not have the zero initialization case here, which would be fine, but the initialization by constant-expression. What am I missing here? Roland
- Follow-Ups:
- Re: [c++-pthreads] Initialization of local static mutex
- From: Mark Mitchell
- Re: [c++-pthreads] Initialization of local static mutex
- References:
- Initialization of local static mutex
- From: Roland Schwarz
- Re: [c++-pthreads] Initialization of local static mutex
- From: Mark Mitchell
- Re: [c++-pthreads] Initialization of local static mutex
- From: Roland Schwarz
- Re: [c++-pthreads] Initialization of local static mutex
- From: Mark Mitchell
- Initialization of local static mutex
- Prev by Date: Re: [c++-pthreads] Initialization of local static mutex
- Next by Date: Re: [c++-pthreads] Initialization of local static mutex
- Previous by thread: Re: [c++-pthreads] Initialization of local static mutex
- Next by thread: Re: [c++-pthreads] Initialization of local static mutex
- Index(es):