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

gcc reports "array subscript is above array bounds" in stringToOid

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Gone away
    • None
    • None
    • Build
    • None
    • gcc 4.5.2 on ubuntu natty armel, gcc 4.4.5 on ubuntu maverick armel
    • ALL

    Description

      I get the following errors building from 1.8.1-rc0 or trunk:

      g++ -o db/json.o -c -Wnon-virtual-dtor -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -fno-builtin-memcmp -O3 -D_SCONS -DMONGO_EXPOSE_MACROS -DXULRUNNER -DOLDJS -DXP_UNIX -I/usr/include/nspr -I/usr/include/xulrunner-2.0/stable -I/usr/include/xulrunner-2.0/unstable -I/usr/include/xulrunner-2.0 -I. -I/usr/local/home/trobinson/dev/v8/include db/json.cpp
      cc1plus: warnings being treated as errors
      db/json.cpp: In function 'mongo::OID mongo::stringToOid(const char*)':
      db/json.cpp:331:49: error: array subscript is above array bounds
      db/json.cpp:331:49: error: array subscript is above array bounds
      db/json.cpp:331:49: error: array subscript is above array bounds
      db/json.cpp:331:49: error: array subscript is above array bounds
      db/json.cpp:331:49: error: array subscript is above array bounds
      db/json.cpp:331:49: error: array subscript is above array bounds
      db/json.cpp:331:49: error: array subscript is above array bounds
      db/json.cpp:331:49: error: array subscript is above array bounds
      scons: *** [db/json.o] Error 1
      scons: building terminated because of errors.

      This may be due to GCC bug 47418: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47418

      The error can be fixed by editing bson/oid.h and moving unsigned char data[12]; to the top of the anonymous union in class OID.

      $ gcc -v
      Using built-in specs.
      COLLECT_GCC=gcc
      COLLECT_LTO_WRAPPER=/usr/lib/arm-linux-gnueabi/gcc/arm-linux-gnueabi/4.5.2/lto-wrapper
      Target: arm-linux-gnueabi
      Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.5.2-6ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.5/README.Bugs --enable-languages=c,c+,fortran,objc,obj-c+ --prefix=/usr --program-suffix=-4.5 --enable-shared --enable-multiarch --with-multiarch-defaults=arm-linux-gnueabi --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib/arm-linux-gnueabi --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.5 --libdir=/usr/lib/arm-linux-gnueabi --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-gold --enable-ld=default --with-plugin-ld=ld.gold --enable-objc-gc --disable-sjlj-exceptions --with-arch=armv7-a --with-float=softfp --with-fpu=vfpv3-d16 --with-mode=thumb --disable-werror --enable-checking=release --build=arm-linux-gnueabi --host=arm-linux-gnueabi --target=arm-linux-gnueabi
      Thread model: posix
      gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-6ubuntu5)

      Also occurs with gcc 4.4.5:

      1. gcc -v
        Using built-in specs.
        Target: arm-linux-gnueabi
        Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.4.4-14ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c+,fortran,objc,obj-c+ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --disable-sjlj-exceptions --with-arch=armv7-a --with-float=softfp --with-fpu=vfpv3-d16 --with-mode=thumb --disable-werror --enable-checking=release --build=arm-linux-gnueabi --host=arm-linux-gnueabi --target=arm-linux-gnueabi
        Thread model: posix
        gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5)

      Attachments

        Activity

          People

            mathias@mongodb.com Mathias Stearn
            scurrilous Trevor Robinson
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: