Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-38595

atomic_word.h, typedefs are misleading, nonportable, noncompliant

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 4.1.7
    • None
    • Internal Code
    • None
    • Fully Compatible
    • ALL
    • Dev Tools 2018-12-31, Dev Tools 2019-01-14

    Description

      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.

      Attachments

        Activity

          People

            billy.donahue@mongodb.com Billy Donahue
            billy.donahue@mongodb.com Billy Donahue
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: