Question: See the following example:

![](https://i.gyazo.com/37e07c37d3f2b9a15231f2f90a2e3b1d.png)

```
    <div class="row">
      <div class="col-2">
        <p>Error</p>
      </div>
      <div class="col-8">
        <div class="progress error" data-toggle="tooltip" data-placement="bottom">
          <div class="progress-bar error-bar" role="progressbar"></div>
        </div>
      </div>
      <div class="col-2">
        <a tabindex="0" data-container="body" data-toggle="popover" data-placement="right" data-content="Some random text">
          <i class="fa fa-info-circle" aria-hidden="true" style="vertical-align: top"></i>
        </a>
      </div>
    </div>

```

The text "Error" is not vertically aligned properly with the prograss bar and font awesome icon. I tried adding `vertical-align: top` to `<p>` but it did not make a difference. How do I correctly vertically align the text?

Answer: 
No, pointer assignment is not guaranteed by either C or C++ to be atomic.

(It's perfectly conceivable, for example, that a pointer spans two registers, and you end up with a mash-up of `x1` and `x2`).

Your code is not thread-safe.
No, this is not safe, it is a data race. It is undefined behavior. The point is not so much what happens on the hardware, but what happens inside the compiler. Compilers have become very clever at optimizing code, they try to prove certain properties of the code to be able to transform it to something that runs faster. To do this, they assume the program does not have undefined behavior.

As pointed out in a [comment](https://stackoverflow.com/questions/46407889/is-multithreading-swapping-2-predefined-pointer-to-1-static-pointer-thread-safe#comment79773585_46407925), it would be a valid and useful optimisation to replace

```
while(1) global = x1;

```

by

```
global = x1;

```

because the compiler will assume `global` is not changed by another thread.