Skip to content

Fix implicit integer precision loss from 64-bit to 32-bit (#5091)#5091

Open
junjieqi wants to merge 3 commits intomainfrom
export-D100588996
Open

Fix implicit integer precision loss from 64-bit to 32-bit (#5091)#5091
junjieqi wants to merge 3 commits intomainfrom
export-D100588996

Conversation

@junjieqi
Copy link
Copy Markdown
Contributor

@junjieqi junjieqi commented Apr 13, 2026

Summary:

Fix 172 clang-diagnostic-shorten-64-to-32 lint warnings across 29 files by adding explicit static_cast<int>() or widening variable types where size_t/idx_t (64-bit) values were implicitly narrowed to int/int32_t (32-bit).

The fixes fall into two categories:

  • Explicit casts: Where the receiving API requires int and the value is known to fit (e.g., vector dimensions, sub-quantizer counts, cluster counts, BLAS parameters)
  • Type widening: Where the variable was unnecessarily narrow (e.g., int nprobesize_t nprobe, int list_nosize_t list_no)

Differential Revision: D100588996

@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync bot commented Apr 13, 2026

@junjieqi has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100588996.

junjieqi added a commit that referenced this pull request Apr 13, 2026
Summary:
Pull Request resolved: #5091

Fix 172 `clang-diagnostic-shorten-64-to-32` lint warnings across 29 files by adding explicit `static_cast<int>()` or widening variable types where `size_t`/`idx_t` (64-bit) values were implicitly narrowed to `int`/`int32_t` (32-bit).

The fixes fall into two categories:
- **Explicit casts**: Where the receiving API requires `int` and the value is known to fit (e.g., vector dimensions, sub-quantizer counts, cluster counts, BLAS parameters)
- **Type widening**: Where the variable was unnecessarily narrow (e.g., `int nprobe` → `size_t nprobe`, `int list_no` → `size_t list_no`)

Differential Revision: D100588996
@meta-codesync meta-codesync bot changed the title Fix implicit integer precision loss from 64-bit to 32-bit Fix implicit integer precision loss from 64-bit to 32-bit (#5091) Apr 13, 2026
@junjieqi junjieqi force-pushed the export-D100588996 branch from 1c6710b to 617da5b Compare April 13, 2026 17:37
junjieqi added a commit that referenced this pull request Apr 13, 2026
Summary:
Pull Request resolved: #5091

Fix 172 `clang-diagnostic-shorten-64-to-32` lint warnings across 29 files by adding explicit `static_cast<int>()` or widening variable types where `size_t`/`idx_t` (64-bit) values were implicitly narrowed to `int`/`int32_t` (32-bit).

The fixes fall into two categories:
- **Explicit casts**: Where the receiving API requires `int` and the value is known to fit (e.g., vector dimensions, sub-quantizer counts, cluster counts, BLAS parameters)
- **Type widening**: Where the variable was unnecessarily narrow (e.g., `int nprobe` → `size_t nprobe`, `int list_no` → `size_t list_no`)

Differential Revision: D100588996
@junjieqi junjieqi force-pushed the export-D100588996 branch from 617da5b to 09ea04e Compare April 13, 2026 17:44

std::vector<double> covd(d_in * d_in);
for (size_t i = 0; i < d_in * d_in; i++)
for (size_t i = 0; i < d_in * d_in; i++) {
eig(d_in, covd.data(), eigenvaluesd.data(), verbose);

for (size_t i = 0; i < d_in * d_in; i++)
for (size_t i = 0; i < d_in * d_in; i++) {
Junjie Qi added 2 commits April 13, 2026 14:00
Summary:
Fix 59 `cppcoreguidelines-pro-type-member-init` lint warnings by adding `{}` value-initialization to uninitialized member fields across 17 files. This ensures all members are zero/null-initialized by default, preventing potential use of uninitialized values.

Affected files: Index.cpp, Index2Layer.cpp, IndexAdditiveQuantizer.cpp, IndexAdditiveQuantizerFastScan.h, IndexBinaryHash.h, IndexBinaryIVF.cpp, IndexFastScan.h, IndexHNSW.h, IndexIVF.h, IndexIVFAdditiveQuantizer.cpp, IndexIVFFastScan.h, IndexIVFFlat.h, IndexIVFPQ.cpp, IndexIVFPQ.h, IndexPQ.cpp, IndexPQ.h, IndexRowwiseMinMax.cpp.

Differential Revision: D100577736
Summary: Fix 136 `readability-braces-around-statements` lint warnings by adding braces to all single-line `if`, `else`, `for`, and `while` statements across 4 files: `IndexLSH.cpp` (14 issues), `IndexIVFPQ.cpp` (36 issues), `IndexPQ.cpp` (25 issues), and `VectorTransform.cpp` (61 issues). This improves code readability and prevents bugs from accidentally adding statements to unbraced blocks.

Differential Revision: D100580151
junjieqi added a commit that referenced this pull request Apr 13, 2026
Summary:
Pull Request resolved: #5091

Fix 172 `clang-diagnostic-shorten-64-to-32` lint warnings across 29 files by adding explicit `static_cast<int>()` or widening variable types where `size_t`/`idx_t` (64-bit) values were implicitly narrowed to `int`/`int32_t` (32-bit).

The fixes fall into two categories:
- **Explicit casts**: Where the receiving API requires `int` and the value is known to fit (e.g., vector dimensions, sub-quantizer counts, cluster counts, BLAS parameters)
- **Type widening**: Where the variable was unnecessarily narrow (e.g., `int nprobe` → `size_t nprobe`, `int list_no` → `size_t list_no`)

Differential Revision: D100588996
@junjieqi junjieqi force-pushed the export-D100588996 branch from 09ea04e to 16ceb5b Compare April 13, 2026 21:05
junjieqi added a commit that referenced this pull request Apr 13, 2026
Summary:
Pull Request resolved: #5091

Fix 172 `clang-diagnostic-shorten-64-to-32` lint warnings across 29 files by adding explicit `static_cast<int>()` or widening variable types where `size_t`/`idx_t` (64-bit) values were implicitly narrowed to `int`/`int32_t` (32-bit).

The fixes fall into two categories:
- **Explicit casts**: Where the receiving API requires `int` and the value is known to fit (e.g., vector dimensions, sub-quantizer counts, cluster counts, BLAS parameters)
- **Type widening**: Where the variable was unnecessarily narrow (e.g., `int nprobe` → `size_t nprobe`, `int list_no` → `size_t list_no`)

Differential Revision: D100588996
@junjieqi junjieqi force-pushed the export-D100588996 branch from 16ceb5b to 16a1c0e Compare April 13, 2026 21:11
Summary:
Pull Request resolved: #5091

Fix 172 `clang-diagnostic-shorten-64-to-32` lint warnings across 29 files by adding explicit `static_cast<int>()` or widening variable types where `size_t`/`idx_t` (64-bit) values were implicitly narrowed to `int`/`int32_t` (32-bit).

The fixes fall into two categories:
- **Explicit casts**: Where the receiving API requires `int` and the value is known to fit (e.g., vector dimensions, sub-quantizer counts, cluster counts, BLAS parameters)
- **Type widening**: Where the variable was unnecessarily narrow (e.g., `int nprobe` → `size_t nprobe`, `int list_no` → `size_t list_no`)

Differential Revision: D100588996
@junjieqi junjieqi force-pushed the export-D100588996 branch from 16a1c0e to c1359b0 Compare April 13, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants