Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-8196

Add warning options to the cppsuite files

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • WT10.0.1, 5.2.0, 5.0.5
    • Affects Version/s: None
    • Component/s: None
    • None
    • 5
    • Storage - Ra 2021-11-01

      Context:
      Through looking at the coverity issues around the CPP test suites WT-8168, I discovered that we don't have flags that allow us to generate compiler warnings. I found that we don't append CFLAGS when compilng cxx files. This is can reflected in cmake build system through

          if(NOT CREATE_TEST_CXX)
              # Don't append the strict diagnostic flags to C++ targets (as these are chosen for C targets).
              set(test_c_flags "${COMPILER_DIAGNOSTIC_FLAGS}")
          endif()
      

      Inside the autoconf build system this is a little harder to parse:

      ac_ext=cpp
      ac_cpp='$CXXCPP $CPPFLAGS'
      ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
      ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
      ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
      

      I don't entirely understand autoconf build system myself, so I will try my best to explain what is happening. This code represents how it compiles for a cpp file. The --enable-strict generates the warning flag for only CFLAGS. In this case, it seems that we don't add in {$CFLAGS}, which means we skip generating the warning flags.

      Task:
      This ticket aims to find a solution where we can add warning flags when compiling CPP tests locally. This will require some investigating if we can utilise the CFLAGS that we generate from --enable-strict or if we need to create a seperate flag specifically for CPP test suites. Once compiler warnings are enabled, there was a lot of warnings that were generated that needs to be addressed.

      We also want evergreen to enable this warning flag to catch the warnings during pull request builds.

            Assignee:
            etienne.petrel@mongodb.com Etienne Petrel
            Reporter:
            jie.chen@mongodb.com Jie Chen
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: