Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-1495

Maybe uninitialized warning with GCC 7 in bsoncxx/document/value.hpp

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.2.0
    • Affects Version/s: None
    • Component/s: Build
    • None
    • Fully Compatible

      When building the driver with GCC 7, the following (false positive?) error is emitted:

      In file included from ../src/bsoncxx/array/value.hpp:21:0,
                       from ../src/bsoncxx/array/view_or_value.hpp:17,
                       from ../src/bsoncxx/builder/concatenate.hpp:17,
                       from ../src/bsoncxx/builder/basic/helpers.hpp:17,
                       from ../src/bsoncxx/builder/basic/sub_array.hpp:17,
                       from ../src/bsoncxx/builder/basic/impl.hpp:17,
                       from ../src/bsoncxx/builder/basic/document.hpp:17,
                       from ../src/bsoncxx/test/view_or_value.cpp:15:
      ../src/bsoncxx/document/value.hpp: In function 'void {anonymous}::____C_A_T_C_H____T_E_S_T____31()':
      ../src/bsoncxx/document/value.hpp:108:63: warning: 'copied.bsoncxx::v_noabi::document::value::_length' may be used uninitialized in this function [-Wmaybe-uninitialized]
           return document::view{static_cast<uint8_t*>(_data.get()), _length};
                                                                     ^~~~~~~
      ../src/bsoncxx/document/value.hpp:108:63: warning: 'moved.bsoncxx::v_noabi::document::value::_length' may be used uninitialized in this function [-Wmaybe-uninitialized]
           return document::view{static_cast<uint8_t*>(_data.get()), _length};
                                                                     ^~~~~~~
      

      As this is a user facing header, this warning is likely to cause problems for users. We should investigate and make a determination as to whether GCC is truly warning us about something dangerous, or is being overzealous, before issuing 3.2.0.

      Note that clang does not issue a warning here.

            Assignee:
            sara.golemon@mongodb.com Sara Golemon
            Reporter:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: