Sign up FAST! Login

Benign data races: what could possibly go wrong? | Intel® Developer Zone


Stashed in: NOT GOOD

To save this post, select a stash from drop-down menu or type in a new one:

But consider we have such an "innocent" code as:

1: int op_count; 2: ... 3: op_count++; // Executed by several threads, it’s OK if it’s not 100% precise.

First, it’s undefined behavior according to C++ standard, C standard, POSIX, Go memory model and any other relevant combination of standards. The fact that the behavior is undefined means that it can lead to basically any runtime behavior, including accidental nuclear missile launch (see an example below).

Liquor? Good.

Guns? Good.

Drive Through? Good.

All Three: NOT GOOD.

You May Also Like: