XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 1.11.0, 1.12.0, 1.13.0, 1.13.1
    • None
    • native client

    Description

      CacheableString objectSize function is returning an incorrect value.
      This class is based upon STL's string implementation, and most of the compilers implementations apply what's called SSO.

      What SSO basically does is if the string occupies less than a certain amount, no extra memory would be allocated in the heap, and the character-sequence would be stored in the object itself. This is typically achieved by using union semantics.
      Right now if SSO applies, objectSize calculates the size of std::string as sizeof(std::string) + m_str.capacity(), which is more than it actually occupies.

      On the other hand starting C++11 STL's strings needs to allocate an extra character
      to keep the null-terminator in the same buffer as the actual string. This is specified in section ยง 21.4.7.1 within the C++11 standard.
      Because of this objectSize should take the null-terminator into account, which was not the case.

      Attachments

        Activity

          People

            gaussianrecurrence Mario Salazar de Torres
            gaussianrecurrence Mario Salazar de Torres
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: