Make ConflictSet non-copyable in C++98/C++03
CI / release (arm64, ubuntu-latest-arm64) (pull_request) Successful in 3m30s
CI / pre-commit (pull_request) Successful in 2m15s
CI / test (-DCMAKE_BUILD_TYPE=Debug, debug) (pull_request) Successful in 3m36s
CI / test (-DCMAKE_CXX_FLAGS=-DUSE_64_BIT=1, 64-bit-versions) (pull_request) Successful in 3m38s
CI / test (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc) (pull_request) Successful in 3m43s
CI / test (-DUSE_SIMD_FALLBACK=ON, simd-fallback) (pull_request) Successful in 3m32s
CI / release (amd64, ubuntu-latest-amd64) (pull_request) Failing after 4m25s
CI / coverage (pull_request) Failing after 3m23s

`ConflictSet(const ConflictSet&)` and `operator=(const ConflictSet&)` were
only deleted for C++11 and later. In C++98/C++03 the compiler implicitly
generated public copy operations, so copying a ConflictSet shared the opaque
`Impl*` and caused a double-free on destruction.

Declare both operations private and leave them undefined when
`__cplusplus <= 199711L`, matching the standard pre-C++11 idiom for
move-only types. Guard the declarations with `defined(__cplusplus)` so
they are not exposed to C90 compilation units.

Closes #48
This commit is contained in:
2026-06-21 19:28:54 -04:00
committed by andrew
parent 6d8b939a81
commit ea6d97c881
+7
View File
@@ -132,6 +132,13 @@ struct __attribute__((__visibility__("default"))) ConflictSet {
private:
Impl *impl;
#if defined(__cplusplus) && __cplusplus <= 199711L
/* Declared private and left undefined to prevent copying in C++98/C++03.
The compiler would otherwise implicitly generate public copy operations,
which share the opaque Impl* and cause a double-free. */
ConflictSet(const ConflictSet &);
ConflictSet &operator=(const ConflictSet &);
#endif
};
} /* namespace weaselab */