title: Lock-free atomic bools on RISC-V in C++
body: <p>I have this C++ code that asserts atomic bools are always lock-free (for reference, this is from Godot Engine):</p>
  <pre class="lang-cpp prettyprint-override"><code>static_assert(std::atomic_bool::is_always_lock_free);
  </code></pre>
  <p>This works fine on x86, but when compiling with GCC for RISC-V, this assert fails with this message:</p>
  <pre class="lang-cpp prettyprint-override"><code>./core/templates/safe_refcount.h:140:34: error: static assertion failed
    140 |  static_assert(std::atomic_bool::is_always_lock_free);
        |                ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
  </code></pre>
  <p>This assert doesn't fail when compiling with Clang (clang++), it only happens with GCC (g++).</p>
  <p>I've been looking around for awhile but the available resources for RISC-V are fairly low. I did find <a href="https://stackoverflow.com/questions/64242067/stdatomicbool-lock-free-inconsistency-on-arm-raspberry-pi-3">this somewhat similar question</a> about lock-free atomics on ARM on a Raspberry Pi 3 where the problem is that the compiler is unaware that atomic bools are guaranteed to be lock-free at compile time. If this is the case, perhaps I am just missing some compiler flag. Alternatively, it is possible that the target architecture is missing a RISC-V extension for this (I have tried both the default <code>rv64imafdc</code>, and <code>rv64gc</code>), but I doubt it since the same target works with Clang.</p>