Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-2880

Struct alignment is less then the default packing size on Windows x86 builds

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.13.0
    • Component/s: libbson
    • None
    • Environment:
      Visual Studio 2017 15.8.8
      x86 (32-bit) target architecture

      On Windows (with ___MSC_VER defined), the bson-macros.h header defines BSON_ALIGN_OF_PTR to 4 for 32-bit target architectures.

      With BSON_EXTRA_ALIGN not defined, this results in structures being declared with an alignment of 4 which is less then the default packing size (which is 8, unless overridden using /Zp which is not recommended in practice) and will be ignored.

      When using libbson in a C++ project and hence compiling libbson headers in C++ mode, this prints the following compiler warning:

      \include\libbson-1.0\bson\bson-types.h(296,0): Warning C4359: '_bson_value_t': Alignment specifier is less than actual alignment (8), and will be ignored.
      

       

            Assignee:
            kevin.albertson@mongodb.com Kevin Albertson
            Reporter:
            saszel Sascha Zelzer
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: