Storage for DocumentStorage::emptyDoc is not guaranteed to have suitable alignment

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 3.3.0
    • Affects Version/s: None
    • Component/s: Internal Code
    • None
    • Fully Compatible
    • ALL
    • Platforms E (01/08/16)
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The following code assumes that the emptyBytes char array is suitably aligned to store an object of type DocumentStorage, but no alignment is enforced:

              static const DocumentStorage& emptyDoc() {
                  static const char emptyBytes[sizeof(DocumentStorage)] = {0};
                  return *reinterpret_cast<const DocumentStorage*>(emptyBytes);
              }
      

      The code is also a strict aliasing violation.

            Assignee:
            Andrew Morrow (Inactive)
            Reporter:
            Andrew Morrow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: