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

Add [[gsl::Pointer]] attribute to class StringData

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 7.0.0-rc0
    • None
    • None
    • None
    • Fully Compatible
    • Server Serverless 2023-04-17

    Description

      The presence of this attribute allows the compiler to catch dangling references.

      std::string_view has this annotation. we should follow suit.

      "This ensures that constructing a StringPiece (StringData in our case) from a temporary (xvalue)
      std::string will produce a compiler warning (error for us). And it
      matches the annotation libc++ does for std::string_view."

      https://bugs.chromium.org/p/chromium/issues/detail?id=1282468

      class [[gsl::Pointer]] StringData {
      ...
      };
      

      https://godbolt.org/z/Kdoec79ar

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: