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

MongoDB 3.4.4 fails to build with gcc 7

    • Fully Compatible
    • ALL

      MongoDB fails to build with gcc 7. The following warning is issued:

      src/mongo/util/time_support.cpp: In function 'void mongo::

      {anonymous}::_dateToCtimeString(mongo::Date_t, mongo::{anonymous}

      ::DateStringBuffer*)':
      src/mongo/util/time_support.cpp:196:6: error: 'snprintf' output may be truncated before the last format character [-Werror=format-truncation=]
      void _dateToCtimeString(Date_t date, DateStringBuffer* result) {
      ^~~~~~~~~~~~~~~~~~
      src/mongo/util/time_support.cpp:206:13: note: 'snprintf' output between 5 and 6 bytes into a destination of size 5
      snprintf(
      milliSecStr, millisSubstrLen + 1, ".%03d", static_cast<int32_t>(date.asInt64() % 1000));

      The issue seems to be that gcc sees that int32_t can be negative (really, why time since epoch can't be negative here?). In this case 5 symbols can be not enough to store string in .%03d format.

            Assignee:
            billy.donahue@mongodb.com Billy Donahue
            Reporter:
            alp Alexander Pyhalov
            Votes:
            0 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: