In paper http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2660.htm an algorithm is presented that does not need to hold a lock during the initialization of a local static variable but still causes concurrent flow of control through the variable definition to wait until initialization finished.
The paper says that this has the advantage of avoiding a possible deadlock
The core problem with function-local static-duration object initialization is that the containing function may be invoked concurrently, and thus the definition may execute concurrently. Failing to synchronize may introduce a race condition. The obvious solution is to synchronize. The problem is that such synchronization may introduce deadlock if the synchronization involves holding a lock while the initializer executes.
Can someone please give an example which demonstrates where the deadlock described above occurs?