Roland Schwarz wrote:
Mark Mitchell wrote:PTHREAD_MUTEX_INITIALIZER is supposed to be a constant-expression (like "-1" or "{ 1, 0 }"), so the initialization will happen before foo is called, typically at program start-up.This was not my question, or concern. I am not asking what is typical, but if it is possible that a standard conforming compiler can suffer from such a race condition.
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.
-- Mark Mitchell CodeSourcery mark@xxxxxxxxxxxxxxxx (650) 331-3385 x713