atomic_word.h, typedefs are misleading, nonportable, noncompliant

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 4.1.7
    • Affects Version/s: None
    • Component/s: Internal Code
    • None
    • Fully Compatible
    • ALL
    • Dev Tools 2018-12-31, Dev Tools 2019-01-14
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In a few places, the header uses identifiers with leading underscore and capital letter, which are reserved.

      https://github.com/mongodb/mongo/blob/63e43f1bb47f7bddf3dc37ad03a2bbee6d2a9423/src/mongo/platform/atomic_word.h

      _ATOMIC_WORD_DECLARE(AtomicUInt32, unsigned);
      _ATOMIC_WORD_DECLARE(AtomicUInt64, unsigned long long);
      _ATOMIC_WORD_DECLARE(AtomicInt32, int);
      _ATOMIC_WORD_DECLARE(AtomicInt64, long long);
      _ATOMIC_WORD_DECLARE(AtomicBool, bool);

      People think AtomicInt32 wraps int32_t and it doesn't.
      This is benign for the AtomicInt32 case, because it's easy to believe that and still be right because 'int32_t' is 'int'.
      But for the 64-bit cases, you'll be wrong sometimes. e.g. std::int64_t is long on Linux. It's only long long on Windows.

      Also we don't need the _ATOMIC_WORD_DECLARE structure.
      All it's doing is providing static asserts that could be inside the AtomicWord class.

            Assignee:
            Billy Donahue
            Reporter:
            Billy Donahue
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: