|
|
|
|
|
by jhdevos
4765 days ago
|
|
There are two different considerations: * what the compiler will enforce: this has nothing to do with thread safety, and will allow what you mention. * what guarantees the standard library will give: [17.6.5.9/3] A C++ standard library function shall not
directly or indirectly modify objects (1.10) accessible by
threads other than the current thread unless the objects
are accessed directly or indirectly via the function’s
non-const arguments, including this. This means that the standard library assumes that your
const objects will be thread safe in order to guarantee
thread-safety itself. Updating a global without synchronization is not thread-safe. |
|