Menu

#237 Compilation fails on GCC 14 due to missing <memory> header in TestDocument.cpp

other
open
nobody
None
5
2025-08-29
2025-08-29
Wang Yiming
No

Environment:

OS: Ubuntu 24.10

Compiler: GCC 14

Commit: a82acd50f9c2e1b38a189635d411b55f670dda8c

Steps to Reproduce:

  1. Create a build directory and runcmake -DENABLE_TESTS=ON ..

  2. Run make cl_test.

Observed Behavior:

The compilation process fails when building src/test/document/TestDocument.cpp, reporting that std::make_unique is not defined. The key error from the compiler is:

/home/user/about_doris/clucene-origin/src/test/document/TestDocument.cpp:69:36: error: make_unique is not a member of std
   69 |   auto char_string_reader = std::make_unique<lucene::util::SStringReader<char>>();
      |                                   ^~~~~~~~~~~
// Compiler Note:
/home/user/about_doris/clucene-origin/src/test/document/TestDocument.cpp:13:1: note: std::make_unique is defined in header <memory>; this is probably fixable by adding ‘#include <memory>
   12 | #include <nanobench.h>
  +++ |+#include <memory>
   13 |

Cause and Solution:

The function std::make_unique was introduced in C++14 and is defined in the <memory> header. Newer compilers like GCC 14 are stricter about requiring explicit header includes.</memory>

Solution: Adding #include <memory> to the top of src/test/document/TestDocument.cpp resolves the compilation error.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB