This is an automated email from the ASF dual-hosted git repository.

colinlee pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/tsfile.git


The following commit(s) were added to refs/heads/develop by this push:
     new e7bdcad4 fix some warning while compiling. (#527)
e7bdcad4 is described below

commit e7bdcad4926ec11cf586322482d51cb57d84c4e4
Author: Colin Lee <[email protected]>
AuthorDate: Wed Jul 2 16:06:51 2025 +0800

    fix some warning while compiling. (#527)
---
 cpp/CMakeLists.txt                                 |  70 ++++----
 cpp/src/common/allocator/mem_alloc.cc              | 197 ++++++---------------
 cpp/src/common/allocator/page_arena.h              |  23 ++-
 cpp/src/common/global.h                            |   1 -
 cpp/src/common/tsfile_common.cc                    |   1 -
 cpp/src/common/tsfile_common.h                     |   2 +-
 cpp/src/encoding/bitpack_decoder.h                 |   6 +-
 cpp/test/common/allocator/page_arena_test.cc       |  26 +++
 .../writer/table_view/tsfile_writer_table_test.cc  |   2 -
 9 files changed, 138 insertions(+), 190 deletions(-)

diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 75684ce0..7ef45118 100755
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -22,49 +22,49 @@ project(TsFile_CPP)
 cmake_policy(SET CMP0079 NEW)
 set(TsFile_CPP_VERSION 2.1.0.dev)
 set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -Wall")
-if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=maybe-uninitialized 
-D__STDC_FORMAT_MACROS")
-endif()
+if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused -Wuninitialized 
-D__STDC_FORMAT_MACROS")
+endif ()
 
 message("cmake using: USE_CPP11=${USE_CPP11}")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
 
-if(DEFINED ENV{CXX})
+if (DEFINED ENV{CXX})
     set(CMAKE_CXX_COMPILER $ENV{CXX})
     message("cmake using: CXX=${CMAKE_CXX_COMPILER}")
-endif()
+endif ()
 
-if(DEFINED ENV{CC})
-  set(CMAKE_C_COMPILER $ENV{CC})
-  message("cmake using: CC=${CMAKE_C_COMPILER}")
-endif()
+if (DEFINED ENV{CC})
+    set(CMAKE_C_COMPILER $ENV{CC})
+    message("cmake using: CC=${CMAKE_C_COMPILER}")
+endif ()
 
 message("cmake using: DEBUG_SE=${DEBUG_SE}")
 if (${DEBUG_SE})
-  add_definitions(-DDEBUG_SE=1)
-  message("add_definitions -DDEBUG_SE=1")
-endif()
+    add_definitions(-DDEBUG_SE=1)
+    message("add_definitions -DDEBUG_SE=1")
+endif ()
 
 if (${COV_ENABLED})
-  add_definitions(-DCOV_ENABLED=1)
-  message("add_definitions -DCOV_ENABLED=1")
-endif()
+    add_definitions(-DCOV_ENABLED=1)
+    message("add_definitions -DCOV_ENABLED=1")
+endif ()
 
 
 if (NOT CMAKE_BUILD_TYPE)
-  set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." 
FORCE)
+    set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." 
FORCE)
 endif ()
 
 message("CMAKE BUILD TYPE " ${CMAKE_BUILD_TYPE})
 if (CMAKE_BUILD_TYPE STREQUAL "Debug")
-  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g")
+    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g")
 elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
-  set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
+    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
 elseif (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
-  set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 
-g")
+    set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 
-g")
 elseif (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
-  set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} 
-ffunction-sections -fdata-sections -Os")
-  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
+    set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} 
-ffunction-sections -fdata-sections -Os")
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
 endif ()
 message("CMAKE DEBUG: CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
 
@@ -72,20 +72,20 @@ message("CMAKE DEBUG: CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
 option(ENABLE_ASAN "Enable Address Sanitizer" OFF)
 
 if (NOT WIN32)
-  if (ENABLE_ASAN)
-    message("Address Sanitizer is enabled.")
+    if (ENABLE_ASAN)
+        message("Address Sanitizer is enabled.")
 
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address 
-fno-omit-frame-pointer")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,undefined 
-fno-omit-frame-pointer")
 
-    if (NOT APPLE)
-      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libasan")
-      set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address 
-static-libasan")
+        if (NOT APPLE)
+            set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libasan")
+            set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} 
-fsanitize=address,undefined -static-libasan -static-libubsan")
+        else ()
+            set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} 
-fsanitize=address,undefined")
+        endif ()
     else ()
-      set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} 
-fsanitize=address")
+        message("Address Sanitizer is disabled.")
     endif ()
-  else ()
-    message("Address Sanitizer is disabled.")
-  endif ()
 endif ()
 
 
@@ -100,11 +100,15 @@ set(PROJECT_SRC_DIR ${PROJECT_SOURCE_DIR}/src)
 set(LIBRARY_INCLUDE_DIR ${PROJECT_BINARY_DIR}/include CACHE STRING "TsFile 
includes")
 set(THIRD_PARTY_INCLUDE ${PROJECT_BINARY_DIR}/third_party)
 
+set(SAVED_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -Wall -std=c++11")
 add_subdirectory(third_party)
+set(CMAKE_CXX_FLAGS "${SAVED_CXX_FLAGS}")
+
 add_subdirectory(src)
 add_subdirectory(test)
 add_subdirectory(examples)
-if(TESTS_ENABLED)
+if (TESTS_ENABLED)
     add_dependencies(TsFile_Test tsfile)
-endif()
+endif ()
 
diff --git a/cpp/src/common/allocator/mem_alloc.cc 
b/cpp/src/common/allocator/mem_alloc.cc
index a1e16d9b..0cc78c8f 100644
--- a/cpp/src/common/allocator/mem_alloc.cc
+++ b/cpp/src/common/allocator/mem_alloc.cc
@@ -63,45 +63,41 @@ const char *g_mod_names[__LAST_MOD_ID] = {
     /* 27 */ "HASH_TABLE",
 };
 
-const uint32_t HEADER_SIZE_4B = 4;
-const uint32_t HEADER_SIZE_8B = 8;
+// Most modern CPUs (e.g., x86_64, Arm) support at least 8-byte alignment,
+// and C++ mandates that alignof(std::max_align_t) reflects the strictest
+// alignment requirement for built-in types (typically 8 or 16 bytes, 
especially
+// with SIMD)
+
+// To ensure that the returned memory pointer from mem_alloc is properly 
aligned
+// for any type, we standardize on an 8-byte header(HEADER_SIZE_8B).
+// If the actual header content is smaller, additional padding is inserted
+// automatically before the aligned payload to preserve alignment.
+// constexpr uint32_t HEADER_SIZE_4B = 4;
+constexpr size_t HEADER_PTR_SIZE = 8;
+// Default alignment is 8 bytes, sufficient for basic types.
+// If SIMD (e.g., SSE/AVX) is introduced later, increase ALIGNMENT to 16/32/64
+// as needed.
+// constexpr size_t ALIGNMENT = alignof(std::max_align_t);
+constexpr size_t ALIGNMENT = 8;
 
 void *mem_alloc(uint32_t size, AllocModID mid) {
     // use 7bit at most
     ASSERT(mid <= 127);
-
-    if (size <= 0xFFFFFF) {
-        // use 3B size + 1B mod
-        char *p = (char *)malloc(size + HEADER_SIZE_4B);
-        if (UNLIKELY(p == nullptr)) {
-            return nullptr;
-        } else {
-            uint32_t header = (size << 8) | ((uint32_t)mid);
-            *((uint32_t *)p) = header;
-            ModStat::get_instance().update_alloc(mid, size);
-            // cppcheck-suppress memleak
-            // cppcheck-suppress unmatchedSuppression
-            return p + HEADER_SIZE_4B;
-        }
-    } else {
-        char *p = (char *)malloc(size + HEADER_SIZE_8B);
-        if (UNLIKELY(p == nullptr)) {
-            std::cout << "alloc big filed for size " << size + HEADER_SIZE_4B
-                      << std::endl;
-            return nullptr;
-        } else {
-            uint64_t large_size = size;
-            uint64_t header = ((large_size) << 8) | (((uint32_t)mid) | (0x80));
-            uint32_t low4b = (uint32_t)(header & 0xFFFFFFFF);
-            uint32_t high4b = (uint32_t)(header >> 32);
-            *(uint32_t *)p = high4b;
-            *(uint32_t *)(p + 4) = low4b;
-            ModStat::get_instance().update_alloc(mid, size);
-            // cppcheck-suppress unmatchedSuppression
-            // cppcheck-suppress memleak
-            return p + HEADER_SIZE_8B;
-        }
+    static_assert(HEADER_PTR_SIZE <= ALIGNMENT,
+                  "Header must fit within alignment");
+    constexpr size_t header_size = ALIGNMENT;
+    const size_t total_size = size + header_size;
+    auto raw = static_cast<char *>(malloc(total_size));
+    if (UNLIKELY(raw == nullptr)) {
+        return nullptr;
     }
+    uint64_t data_size = size;
+    uint64_t header = (data_size << 8) | static_cast<uint32_t>(mid);
+    auto low4b = static_cast<uint32_t>(header & 0xFFFFFFFF);
+    auto high4b = static_cast<uint32_t>(header >> 32);
+    *reinterpret_cast<uint32_t *>(raw) = high4b;
+    *reinterpret_cast<uint32_t *>(raw + 4) = low4b;
+    return raw + header_size;
 }
 
 #ifndef _WIN32
@@ -132,109 +128,39 @@ void printCallers() {
 #endif
 
 void mem_free(void *ptr) {
-    // try as 4Byte header
-    char *p = (char *)ptr;
-    uint32_t header = *(uint32_t *)(p - HEADER_SIZE_4B);
-    if ((header & 0x80) == 0) {
-        // 4Byte header
-        uint32_t size = header >> 8;
-        AllocModID mid = (AllocModID)(header & 0x7F);
-        ModStat::get_instance().update_free(mid, size);
-        ::free(p - HEADER_SIZE_4B);
-    } else {
-        // 8Byte header
-        uint64_t header8b = ((uint64_t)(*(uint32_t *)(p - 4))) |
-                            ((uint64_t)(*(uint32_t *)(p - 8)) << 32);
-        AllocModID mid = (AllocModID)(header8b & 0x7F);
-        uint32_t size = (uint32_t)(header8b >> 8);
-        ModStat::get_instance().update_free(mid, size);
-        ::free(p - HEADER_SIZE_8B);
-    }
+    char *p = static_cast<char *>(ptr);
+    char *raw_ptr = p - ALIGNMENT;
+    uint64_t header =
+        static_cast<uint64_t>(*reinterpret_cast<uint32_t *>(raw_ptr + 4)) |
+        (static_cast<uint64_t>(*reinterpret_cast<uint32_t *>(raw_ptr)) << 32);
+    auto mid = static_cast<AllocModID>(header & 0x7F);
+    auto size = static_cast<uint32_t>(header >> 8);
+    ModStat::get_instance().update_free(mid, size);
+    ::free(raw_ptr);
 }
 
 void *mem_realloc(void *ptr, uint32_t size) {
-    AllocModID mid_org;
-    uint32_t size_org;
-    char *p = (char *)ptr;
-    uint32_t header_org =
-        *(uint32_t *)(p - HEADER_SIZE_4B);  // try as 4Byte header
-    if ((header_org & 0x80) == 0) {
-        // header_org is 4byte
-        size_org = header_org >> 8;
-        mid_org = (AllocModID)(header_org & 0x7F);
-        if (size <= 0xFFFFFF) {
-            p = (char *)realloc(p - HEADER_SIZE_4B, size + HEADER_SIZE_4B);
-            if (UNLIKELY(p == nullptr)) {
-                return nullptr;
-            } else {
-                uint32_t header =
-                    (size << 8) | ((uint32_t)mid_org);  // size changed
-                *((uint32_t *)p) = header;
-                ModStat::get_instance().update_alloc(
-                    mid_org, int32_t(size) - int32_t(size_org));
-                return p + HEADER_SIZE_4B;
-            }
-        } else {  // size > 0xFFFFFF, realloc(os_p, size + header_len)
-            p = (char *)realloc(p - HEADER_SIZE_4B, size + HEADER_SIZE_8B);
-            if (UNLIKELY(p == nullptr)) {
-                return nullptr;
-            } else {
-                std::memmove(p + HEADER_SIZE_8B, p + HEADER_SIZE_4B, size_org);
-                // reconstruct 8-byte header
-                uint64_t large_size = size;
-                uint64_t header =
-                    ((large_size) << 8) | (((uint32_t)mid_org) | (0x80));
-                uint32_t low4b = (uint32_t)(header & 0xFFFFFFFF);
-                uint32_t high4b = (uint32_t)(header >> 32);
-                *(uint32_t *)p = high4b;
-                *(uint32_t *)(p + 4) = low4b;
-                ModStat::get_instance().update_alloc(
-                    mid_org, int32_t(size) - int32_t(size_org));
-                return p + HEADER_SIZE_8B;
-            }
-        }
-    } else {  // header_org is 8byte
-        uint64_t header =
-            ((uint64_t)(*(uint32_t *)(p - 4))) |
-            ((uint64_t)(*(uint32_t *)(p - 8)) << 32);  // 8Byte header
-        mid_org = (AllocModID)(header & 0x7F);
-        size_org = (uint32_t)(header >> 8);
-        if (size <= 0xFFFFFF) {
-            uint32_t save_data =
-                *(uint32_t *)(p - HEADER_SIZE_8B + HEADER_SIZE_4B + size);
-            p = (char *)realloc(p - HEADER_SIZE_8B, size + HEADER_SIZE_4B);
-            if (UNLIKELY(p == nullptr)) {
-                return nullptr;
-            } else {
-                std::memmove(p + HEADER_SIZE_4B, p + HEADER_SIZE_8B,
-                             size - HEADER_SIZE_4B);
-                // reconstruct 4-byte header
-                uint32_t header4b = (size << 8) | (((uint32_t)mid_org));
-                *((uint32_t *)p) = header4b;
-                // reconstruct data
-                *(uint32_t *)((char *)p + size - 4) = save_data;
-                ModStat::get_instance().update_alloc(
-                    mid_org, int32_t(size) - int32_t(size_org));
-                return p + HEADER_SIZE_4B;
-            }
-        } else {
-            p = (char *)realloc(p - HEADER_SIZE_8B, size + HEADER_SIZE_8B);
-            if (UNLIKELY(p == nullptr)) {
-                return nullptr;
-            } else {
-                uint64_t large_size = size;
-                uint64_t header8b =
-                    ((large_size) << 8) | (((uint32_t)mid_org) | (0x80));
-                uint32_t low4b = (uint32_t)(header8b & 0xFFFFFFFF);
-                uint32_t high4b = (uint32_t)(header8b >> 32);
-                *(uint32_t *)p = high4b;
-                *(uint32_t *)(p + 4) = low4b;
-                ModStat::get_instance().update_alloc(
-                    mid_org, int32_t(size) - int32_t(size_org));
-                return p + HEADER_SIZE_8B;
-            }
-        }
+    char *p = static_cast<char *>(ptr);
+    char *raw_ptr = p - ALIGNMENT;
+    const uint64_t header =
+        static_cast<uint64_t>(*reinterpret_cast<uint32_t *>(raw_ptr + 4)) |
+        (static_cast<uint64_t>(*reinterpret_cast<uint32_t *>(raw_ptr)) << 32);
+    auto mid = static_cast<AllocModID>(header & 0x7F);
+    auto original_size = static_cast<uint32_t>(header >> 8);
+    p = static_cast<char *>(realloc(raw_ptr, size + ALIGNMENT));
+    if (UNLIKELY(p == nullptr)) {
+        return nullptr;
     }
+
+    uint64_t data_size = size;
+    uint64_t header_new = (data_size << 8) | static_cast<uint32_t>(mid);
+    auto low4b = static_cast<uint32_t>(header_new & 0xFFFFFFFF);
+    auto high4b = static_cast<uint32_t>(header_new >> 32);
+    *reinterpret_cast<uint32_t *>(p) = high4b;
+    *reinterpret_cast<uint32_t *>(p + 4) = low4b;
+    ModStat::get_instance().update_alloc(
+        mid, int32_t(size) - int32_t(original_size));
+    return p + ALIGNMENT;
 }
 
 void ModStat::init() {
@@ -247,11 +173,6 @@ void ModStat::init() {
 
 void ModStat::destroy() { ::free(stat_arr_); }
 
-// TODO return to SQL
-void ModStat::print_stat() {
-    //
-}
-
 BaseAllocator g_base_allocator;
 
 }  // end namespace common
\ No newline at end of file
diff --git a/cpp/src/common/allocator/page_arena.h 
b/cpp/src/common/allocator/page_arena.h
index b8053cfb..938cac1a 100644
--- a/cpp/src/common/allocator/page_arena.h
+++ b/cpp/src/common/allocator/page_arena.h
@@ -20,6 +20,8 @@
 #ifndef COMMON_ALLOCATOR_PAGE_ARENA_H
 #define COMMON_ALLOCATOR_PAGE_ARENA_H
 
+#include <cstddef>
+
 #include "alloc_base.h"
 
 namespace common {
@@ -68,20 +70,17 @@ class PageArena {
                 (char *)this + sizeof(Page);  // equals to (char*)(this+1)
             page_end_ = cur_alloc_ + page_size;
         }
-        INLINE char *alloc(uint32_t size) {
-            if (cur_alloc_ + size > page_end_) {
+        INLINE char *alloc(uint32_t size,
+                           size_t alignment = alignof(std::max_align_t)) {
+            auto current = reinterpret_cast<uintptr_t>(cur_alloc_);
+            uintptr_t aligned = (current + alignment - 1) & ~(alignment - 1);
+            char *ret = reinterpret_cast<char *>(aligned);
+            if (ret + size > page_end_) {
                 return nullptr;
-            } else {
-                char *ret = cur_alloc_;
-                cur_alloc_ += size;
-                return ret;
-                //        char *ret = cur_alloc_;
-                //        cur_alloc_ += size;
-                //        int address = 
reinterpret_cast<uintptr_t>(cur_alloc_);
-                //        int new_addr = (address + 3) & (~3);
-                //        cur_alloc_ = reinterpret_cast<char *>(new_addr);
-                //        return ret;
             }
+
+            cur_alloc_ = ret + size;
+            return ret;
         }
 
        public:
diff --git a/cpp/src/common/global.h b/cpp/src/common/global.h
index 3f331460..50ca8c8a 100644
--- a/cpp/src/common/global.h
+++ b/cpp/src/common/global.h
@@ -58,7 +58,6 @@ FORCE_INLINE int set_global_time_compression(uint8_t 
compression) {
 }
 
 FORCE_INLINE int set_datatype_encoding(uint8_t data_type, uint8_t encoding) {
-    int code = E_OK;
     TSDataType dtype = static_cast<TSDataType>(data_type);
     ASSERT(dtype >= BOOLEAN && dtype <= STRING);
     TSEncoding encoding_type = static_cast<TSEncoding>(encoding);
diff --git a/cpp/src/common/tsfile_common.cc b/cpp/src/common/tsfile_common.cc
index 06c415bc..31c718b4 100644
--- a/cpp/src/common/tsfile_common.cc
+++ b/cpp/src/common/tsfile_common.cc
@@ -29,7 +29,6 @@ using namespace common;
 namespace storage {
 
 const char *MAGIC_STRING_TSFILE = "TsFile";
-const int MAGIC_STRING_TSFILE_LEN = 6;
 const char VERSION_NUM_BYTE = 0x04;  // 0x03;
 const char CHUNK_GROUP_HEADER_MARKER = 0;
 const char CHUNK_HEADER_MARKER = 1;
diff --git a/cpp/src/common/tsfile_common.h b/cpp/src/common/tsfile_common.h
index 582ae604..dd22ca40 100644
--- a/cpp/src/common/tsfile_common.h
+++ b/cpp/src/common/tsfile_common.h
@@ -40,7 +40,7 @@
 namespace storage {
 
 extern const char *MAGIC_STRING_TSFILE;
-extern const int MAGIC_STRING_TSFILE_LEN;
+constexpr int MAGIC_STRING_TSFILE_LEN = 6;
 extern const char VERSION_NUM_BYTE;
 extern const char CHUNK_GROUP_HEADER_MARKER;
 extern const char CHUNK_HEADER_MARKER;
diff --git a/cpp/src/encoding/bitpack_decoder.h 
b/cpp/src/encoding/bitpack_decoder.h
index 099afc79..61c30d1a 100644
--- a/cpp/src/encoding/bitpack_decoder.h
+++ b/cpp/src/encoding/bitpack_decoder.h
@@ -124,17 +124,19 @@ class BitPackDecoder {
             delete[] current_buffer_;
         }
         current_buffer_ = new int64_t[bit_packed_group_count * 8];
-        unsigned char bytes[bit_packed_group_count * bit_width_];
         int bytes_to_read = bit_packed_group_count * bit_width_;
         if (bytes_to_read > (int)byte_cache_.remaining_size()) {
             bytes_to_read = byte_cache_.remaining_size();
         }
+        std::vector<unsigned char> bytes(bytes_to_read);
+
         for (int i = 0; i < bytes_to_read; i++) {
             common::SerializationUtil::read_ui8(bytes[i], byte_cache_);
         }
+
         // save all int values in currentBuffer
         packer_->unpack_all_values(
-            bytes, bytes_to_read,
+            bytes.data(), bytes_to_read,
             current_buffer_);  // decode from bytes, save in currentBuffer
     }
 
diff --git a/cpp/test/common/allocator/page_arena_test.cc 
b/cpp/test/common/allocator/page_arena_test.cc
index ff231e6c..0d34e95d 100644
--- a/cpp/test/common/allocator/page_arena_test.cc
+++ b/cpp/test/common/allocator/page_arena_test.cc
@@ -55,4 +55,30 @@ TEST(PageArenaTest, AllocMoreThanPageSize) {
     page_arena.reset();
 }
 
+struct MyStruct {
+    double x;
+    int64_t y;
+    char buf[1721];
+};
+
+TEST(PageArenaAlignedTest, AlignmentWithBuildinTypes) {
+    PageArena page_arena;
+    int page_size = 1024;
+    page_arena.init(page_size, MOD_DEFAULT);
+    for (int i = 0; i < 10; i++) {
+        void* p1 = page_arena.alloc(sizeof(double));
+        ASSERT_NE(p1, nullptr);
+        EXPECT_EQ(reinterpret_cast<uintptr_t>(p1) % alignof(double), 0u);
+
+        void* p2 = page_arena.alloc(sizeof(int64_t));
+        ASSERT_NE(p2, nullptr);
+        EXPECT_EQ(reinterpret_cast<uintptr_t>(p2) % alignof(int64_t), 0u);
+
+        void* p3 = page_arena.alloc(sizeof(MyStruct));
+        ASSERT_NE(p3, nullptr);
+        EXPECT_EQ(reinterpret_cast<uintptr_t>(p3) % alignof(MyStruct), 0u);
+    }
+    page_arena.reset();
+}
+
 }  // namespace common
\ No newline at end of file
diff --git a/cpp/test/writer/table_view/tsfile_writer_table_test.cc 
b/cpp/test/writer/table_view/tsfile_writer_table_test.cc
index d446d604..73573f73 100644
--- a/cpp/test/writer/table_view/tsfile_writer_table_test.cc
+++ b/cpp/test/writer/table_view/tsfile_writer_table_test.cc
@@ -570,7 +570,6 @@ TEST_F(TsFileWriterTableTest, WriteWithNullAndEmptyTag) {
 
     auto table_result_set = (TableResultSet*)ret;
     bool has_next = false;
-    int cur_line = 0;
     auto schema = table_result_set->get_metadata();
     while (IS_SUCC(table_result_set->next(has_next)) && has_next) {
         int64_t timestamp = table_result_set->get_value<int64_t>(1);
@@ -745,7 +744,6 @@ TEST_F(TsFileWriterTableTest, WriteDataWithEmptyField) {
 
     auto table_result_set = (TableResultSet*)ret;
     bool has_next = false;
-    int cur_line = 0;
     auto schema = table_result_set->get_metadata();
     while (IS_SUCC(table_result_set->next(has_next)) && has_next) {
         int64_t timestamp = table_result_set->get_value<int64_t>(1);

Reply via email to