Skip to content

Fix uninitialized class/struct members in public headers#1922

Open
maxwbuckley wants to merge 2 commits intorapidsai:mainfrom
maxwbuckley:fix-uninitialized-members-v2
Open

Fix uninitialized class/struct members in public headers#1922
maxwbuckley wants to merge 2 commits intorapidsai:mainfrom
maxwbuckley:fix-uninitialized-members-v2

Conversation

@maxwbuckley
Copy link
Contributor

@maxwbuckley maxwbuckley commented Mar 16, 2026

Summary

  • Initialize POD members with sensible defaults to prevent undefined behavior when users create instances without explicitly setting all fields
  • Fix base_filter to have a virtual destructor for safe polymorphic deletion
  • Clean up empty constructor syntax ({};{}) and use = default for trivial destructors

Rebase of #1735 (accidentally closed when I made my copy of cuvs private) onto latest main.

Files Changed

File Changes
cluster/agglomerative.hpp min_samples = 5
distance/distance.hpp KernelParams: kernel = LINEAR, degree = 3, gamma = 1.0, coef0 = 0.0
distance/grammian.hpp cublas_handle = nullptr, constructor/destructor cleanup
neighbors/ball_cover.hpp index_trained = false
neighbors/common.hpp virtual ~base_filter(), num_ranks_ = 0
neighbors/hnsw.hpp ef = 200
neighbors/vamana.hpp pq_codebook_size = 0, pq_dim = 0
preprocessing/spectral_embedding.hpp n_components = 2, n_neighbors = 15, etc.

Test plan

  • Existing tests pass (no behavioral change for code that explicitly sets fields)
  • Default values match documentation/usage patterns

🤖 Generated with Claude Code

@copy-pr-bot
Copy link

copy-pr-bot bot commented Mar 16, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@aamijar aamijar added non-breaking Introduces a non-breaking change improvement Improves an existing functionality labels Mar 16, 2026
@aamijar
Copy link
Member

aamijar commented Mar 16, 2026

/ok to test 3a90ebe

maxwbuckley and others added 2 commits March 19, 2026 21:34
Initialize POD members with sensible defaults to prevent undefined behavior
when users create instances without explicitly setting all fields:

- cluster/agglomerative.hpp: min_samples = 5
- distance/distance.hpp: KernelParams defaults (LINEAR, degree=3, gamma=1.0, coef0=0.0)
- distance/grammian.hpp: cublas_handle = nullptr, fix empty constructor syntax
- neighbors/ball_cover.hpp: index_trained = false
- neighbors/common.hpp: make base_filter destructor virtual, num_ranks_ = 0
- neighbors/hnsw.hpp: ef = 200
- neighbors/vamana.hpp: pq_codebook_size = 0, pq_dim = 0
- preprocessing/spectral_embedding.hpp: n_components=2, n_neighbors=15, etc.

Also fixes base_filter to have a virtual destructor for safe polymorphic deletion.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@maxwbuckley maxwbuckley force-pushed the fix-uninitialized-members-v2 branch from 3a90ebe to 35c96ec Compare March 19, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

Development

Successfully merging this pull request may close these issues.

2 participants