Skip to content

Comments

Fix clang warnings on Windows#28748

Open
fmeum wants to merge 1 commit intobazelbuild:masterfrom
fmeum:clang-warnings
Open

Fix clang warnings on Windows#28748
fmeum wants to merge 1 commit intobazelbuild:masterfrom
fmeum:clang-warnings

Conversation

@fmeum
Copy link
Collaborator

@fmeum fmeum commented Feb 23, 2026

Description

Compiling with clang rather than MSVC generates more warnings on Windows, some of which point to legitimate logic bugs, memory safety issues or dead code.

Motivation

Build API Changes

No

Checklist

  • I have added tests for the new use cases (if any).
  • I have updated the documentation (if applicable).

Release Notes

RELNOTES: None

@github-actions github-actions bot added team-Rules-CPP Issues for C++ rules awaiting-review PR is awaiting review from an assigned reviewer labels Feb 23, 2026
@fmeum
Copy link
Collaborator Author

fmeum commented Feb 23, 2026

@bazel-io fork 9.1.0

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes clang warnings on Windows that point to legitimate logic bugs and undefined behavior. Compiling with clang instead of MSVC generates more warnings, helping to identify real issues in the codebase.

Changes:

  • Fixed constexpr pointer type declarations for string literals
  • Removed unused variables and functions
  • Corrected struct initialization syntax from {0} to {} where clang warned
  • Fixed critical logic bug in IsStandardTerminal() where wrong handle was being checked
  • Fixed parameter naming shadowing issue in SignalHandler::Install()

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tools/test/windows/tw.cc Fixed constexpr declaration and removed unused helper functions
third_party/def_parser/BUILD Added compiler flag to suppress unused variable warning (has issue)
src/tools/launcher/util/launcher_util.cc Removed unused size variable from FormatMessageA call
src/main/native/windows/processes-jni.cc Updated LARGE_INTEGER initialization syntax
src/main/native/windows/process.cc Updated struct initialization and removed unused DupeHandle function
src/main/cpp/util/errors_windows.cc Removed unused size variable from FormatMessageA call
src/main/cpp/blaze_util_windows.cc Fixed parameter shadowing, struct initialization, removed unused function, and critically fixed loop variable bug in IsStandardTerminal

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Compiling with clang rather than MSVC generates more warnings on Windows, some of which point to legitimate logic bugs and UB.
@meteorcloudy meteorcloudy added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Feb 23, 2026
@meteorcloudy
Copy link
Member

@iancha1992 third_party/def_parser/BUILD has to be merged separately.

hdrs = ["def_parser.h"],
copts = select({
"@rules_cc//cc/compiler:clang": [
# third_party/def_parser/def_parser.cc:349:10: warning: unused variable 'size' [-Wunused-variable]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't we just remove the unused variable here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally team-Rules-CPP Issues for C++ rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants