Fix -Wnontrivial-memcall compile error in test_reconciliation_tracking.cpp

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • WT12.0.0, 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: Btree
    • None
    • Storage Engines
    • 83.519
    • None
    • None

      Symptom

      New Apple Clang (shipped with recent Xcode / CLT updates) introduced the -Wnontrivial-memcall diagnostic, which rejects memset calls whose first argument is a pointer to a non-trivially copyable C++ type. Because WiredTiger compiles with -Werror, clean builds on macOS now fail with:

      error: first argument in call to 'memset' is a pointer to non-trivially copyable type 'WT_BM'
      

      Affected file

      test/catch2/misc_tests/test_reconciliation_tracking.cpp, lines 40, 43, 46 — three memset calls on WT_BM, WT_BTREE, and WT_DATA_HANDLE.

      Root cause

      Apple Clang added -Wnontrivial-memcall to flag potentially unsafe memset / memcpy usage on types with non-trivial copy semantics. The three types in the test helper setup_failing_bm() are C structs with C++ wrappers that are considered non-trivially copyable by the new compiler version.

      Fix

      Cast the first argument to void * to suppress the diagnostic (standard practice; the zeroing is intentional and safe here):

      // Before
      memset(bm, 0, sizeof(*bm));
      memset(btree, 0, sizeof(*btree));
      memset(dhandle, 0, sizeof(*dhandle));
      
      // After
      memset((void *)bm, 0, sizeof(*bm));
      memset((void *)btree, 0, sizeof(*btree));
      memset((void *)dhandle, 0, sizeof(*dhandle));
      

      Repro

      Run wb (or cmake --build) on macOS with a recent Apple Clang toolchain. The error appears on a clean build.

            Assignee:
            [DO NOT USE] Backlog - Storage Engines Team
            Reporter:
            Shoufu Du
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: