mirror of
https://github.com/facebookresearch/faiss.git
synced 2026-10-12 02:13:36 +00:00
Default-initialize SVSStorageKind in IndexSVSVamana (#5054)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5054 `IndexSVSVamana::storage_kind` was declared without a default initializer, and the default constructor is `= default`, so the field was left uninitialized in default-constructed instances. This is undefined behavior any time the value is read — including serialization via `write_index`, which writes the garbage value to disk. Add `= SVS_FP32` as the default initializer, matching the default used by the parameterized constructor `IndexSVSVamana(d, degree, metric, storage)`. This is a safe, behavior-preserving change: - The parameterized constructor already defaults to `SVS_FP32`, so any code constructing an index with arguments is unaffected. - The two derived classes (`IndexSVSVamanaLVQ`, `IndexSVSVamanaLeanVec`) explicitly set `storage_kind` in their own default constructors, so they are also unaffected. - The only code path that changes behavior is default construction of `IndexSVSVamana` itself, which previously produced an uninitialized (UB) value and now produces `SVS_FP32`. Reviewed By: mnorris11 Differential Revision: D99891611 fbshipit-source-id: da6acff7bdeb5668a2bf5f3b585bc1a3179004b9
This commit is contained in:
committed by
meta-codesync[bot]
parent
c1e48a2ce1
commit
e899476ceb
@@ -86,7 +86,7 @@ struct IndexSVSVamana : Index {
|
||||
size_t max_candidate_pool_size = 200;
|
||||
bool use_full_search_history = true;
|
||||
|
||||
SVSStorageKind storage_kind;
|
||||
SVSStorageKind storage_kind = SVS_FP32;
|
||||
|
||||
IndexSVSVamana();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user