Skip to content

fix: add CMake warning infrastructure (opt-in strict compiler warnings)#4932

Open
maxwbuckley wants to merge 2 commits intofacebookresearch:mainfrom
maxwbuckley:fix/warnings-cmake-infra
Open

fix: add CMake warning infrastructure (opt-in strict compiler warnings)#4932
maxwbuckley wants to merge 2 commits intofacebookresearch:mainfrom
maxwbuckley:fix/warnings-cmake-infra

Conversation

@maxwbuckley
Copy link
Copy Markdown
Contributor

@maxwbuckley maxwbuckley commented Mar 17, 2026

Summary

  • Add configurable compiler warning infrastructure (cmake/StrictCompilerWarnings.cmake) with 3 warning levels (basic, standard, strict) and optional -Werror support
  • Apply faiss_add_warnings() to all build targets via CMakeLists.txt updates
  • Add CI workflow job for warning-level builds
  • Document warning levels in CONTRIBUTING.md
  • Fix compiler warnings caught by the new CI job:
    • ResultHandler.h: sign-compare (int vs size_t loop variable)
    • IDSelector.h: unused parameter in IDSelectorAll::is_member
    • io_macros.h: redundant size >= 0 checks on unsigned size_t in READVECTOR/READXBVECTOR
    • OnDiskInvertedLists.cpp: sign-compare and type-limits warnings across several variables

Default is level 0 (off) so this is fully opt-in and does not break existing builds.

Part 1/13 of the compiler warnings cleanup (split from #4810 per maintainer request).

Test plan

  • Default build (level 0) unchanged
  • No functional changes
  • Warnings CI job passes with -Werror

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync bot commented Mar 17, 2026

@alibeklfc has imported this pull request. If you are a Meta employee, you can view this in D96995151.

@maxwbuckley maxwbuckley force-pushed the fix/warnings-cmake-infra branch from 305b422 to eed281b Compare March 18, 2026 10:01
Mechanical fixes for compiler warnings found with -Wall -Wextra -Wshadow.
No functional changes — only variable renames, unused parameter annotations,
signed/unsigned casts, and [[fallthrough]] attributes.

Part 1/13 of the compiler warnings cleanup (split from PR facebookresearch#4810).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…s, and OnDiskInvertedLists

Fix sign-compare, unused-parameter, and type-limits warnings caught by
the new -Werror warnings CI job.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant