https://issues.dlang.org/show_bug.cgi?id=23579
Iain Buclaw <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P1 |P3 CC| |[email protected] --- Comment #4 from Iain Buclaw <[email protected]> --- C++ supports and implements this by generating the following code: ``` void v(int a) { static bool __guard_for_b = false; static int b = 0; if (__guard_for_b == 0) { b = a; __guard_for_b = true; } } ``` Things get hairier with __gshared variables. ``` void v(int a) { __gshared bool __guard_for_b = false; __gshared int b = 0; if (core.atomic.atomicLoad!(MemoryOrder.acq)(__guard_for_b) == 0) { synchronized // __cxa_guard_acquire(&__guard_for_b) { b = a; __guard_for_b = true; } // __cxa_guard_release(&__guard_for_b) } } ``` I don't think we really need such an expensive run-time feature in D. --
