Skip to content

Commit b870b08

Browse files
fix: explicitly delete CSVReader move assignment operator (contains std::mutex) (#292)
* fix: explicitly delete CSVReader move assignment (contains std::mutex) CSVReader holds a std::mutex member (read_csv_exception_lock), which has a deleted move assignment operator. Declaring operator=(CSVReader&&) as = default therefore causes the function to be implicitly deleted, which triggers -Wdefaulted-function-deleted on Clang (Apple clang 17 / LLVM). Replace the misleading = default with an explicit = delete so the intent is clear and the compiler diagnostic is resolved. Fixes build warning: warning: explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted] * Add clang to build matrix --------- Co-authored-by: Vincent La <vincela9@gmail.com>
1 parent 7f7e417 commit b870b08

5 files changed

Lines changed: 19 additions & 14 deletions

File tree

.github/workflows/cmake-multi-platform.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
matrix:
2626
os: [windows-latest, ubuntu-latest]
2727
build_type: [Release]
28-
c_compiler: [gcc, cl]
28+
c_compiler: [gcc, cl, clang]
2929
cxx_standard: [17, 20]
3030
include:
3131
- os: windows-latest
@@ -34,9 +34,14 @@ jobs:
3434
- os: ubuntu-latest
3535
c_compiler: gcc
3636
cpp_compiler: g++
37+
- os: ubuntu-latest
38+
c_compiler: clang
39+
cpp_compiler: clang++
3740
exclude:
3841
- os: windows-latest
3942
c_compiler: gcc
43+
- os: windows-latest
44+
c_compiler: clang
4045
- os: ubuntu-latest
4146
c_compiler: cl
4247

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ if (CSV_DEVELOPER)
7676
endif()
7777

7878
# More error messages, treat warnings as errors.
79-
if (UNIX)
79+
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
8080
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
8181
-Wall -Wextra -Wpedantic -Wsign-compare \
8282
-Wwrite-strings -Wpointer-arith -Winit-self \

include/internal/csv_reader.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ namespace csv {
205205
}
206206
///@}
207207

208-
CSVReader(const CSVReader&) = delete; // No copy constructor
209-
CSVReader(CSVReader&&) = default; // Move constructor
210-
CSVReader& operator=(const CSVReader&) = delete; // No copy assignment
211-
CSVReader& operator=(CSVReader&& other) = default;
208+
CSVReader(const CSVReader&) = delete; ///< Not copyable
209+
CSVReader(CSVReader&&) = delete; ///< Not movable: contains std::mutex
210+
CSVReader& operator=(const CSVReader&) = delete; ///< Not copyable
211+
CSVReader& operator=(CSVReader&&) = delete; ///< Not movable: contains std::mutex
212212
~CSVReader() {
213213
if (this->read_csv_worker.joinable()) {
214214
this->read_csv_worker.join();

single_include/csv.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5317,10 +5317,10 @@ namespace csv {
53175317
}
53185318
///@}
53195319

5320-
CSVReader(const CSVReader&) = delete; // No copy constructor
5321-
CSVReader(CSVReader&&) = default; // Move constructor
5322-
CSVReader& operator=(const CSVReader&) = delete; // No copy assignment
5323-
CSVReader& operator=(CSVReader&& other) = default;
5320+
CSVReader(const CSVReader&) = delete; ///< Not copyable
5321+
CSVReader(CSVReader&&) = delete; ///< Not movable: contains std::mutex
5322+
CSVReader& operator=(const CSVReader&) = delete; ///< Not copyable
5323+
CSVReader& operator=(CSVReader&&) = delete; ///< Not movable: contains std::mutex
53245324
~CSVReader() {
53255325
if (this->read_csv_worker.joinable()) {
53265326
this->read_csv_worker.join();

single_include_test/csv.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5317,10 +5317,10 @@ namespace csv {
53175317
}
53185318
///@}
53195319

5320-
CSVReader(const CSVReader&) = delete; // No copy constructor
5321-
CSVReader(CSVReader&&) = default; // Move constructor
5322-
CSVReader& operator=(const CSVReader&) = delete; // No copy assignment
5323-
CSVReader& operator=(CSVReader&& other) = default;
5320+
CSVReader(const CSVReader&) = delete; ///< Not copyable
5321+
CSVReader(CSVReader&&) = delete; ///< Not movable: contains std::mutex
5322+
CSVReader& operator=(const CSVReader&) = delete; ///< Not copyable
5323+
CSVReader& operator=(CSVReader&&) = delete; ///< Not movable: contains std::mutex
53245324
~CSVReader() {
53255325
if (this->read_csv_worker.joinable()) {
53265326
this->read_csv_worker.join();

0 commit comments

Comments
 (0)