Fix issues flagged by compiling clr.aot with clang on Windows - #131183
Merged
MichalStrehovsky merged 1 commit intoJul 23, 2026
Conversation
Out of curiosity I let copilot build clr.aot with clang.
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts several native/runtime sources to compile cleanly under clang on Windows by addressing common warning patterns (signed/unsigned loop indices, format-string type mismatches, unreachable control-flow annotations, and header include casing).
Changes:
- Switch loop indices to
size_twhere the bound issizeof/ARRAY_SIZE-derived. - Adjust GUID formatting to better match
snprintf’s%xexpectations. - Minor portability/diagnostic fixes: add missing standard include, add
UNREACHABLE(), fix header include casing, and mark a destructorvirtual.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/native/minipal/xoshiro128pp.c | Add <stddef.h> and use size_t loop index to avoid signed/unsigned comparisons. |
| src/native/minipal/guid.c | Cast GUID components for snprintf formatting (but see review comment about completing the casts). |
| src/coreclr/utilcode/stacktrace.cpp | Use size_t for an ARRAY_SIZE-bounded loop. |
| src/coreclr/utilcode/pedecoder.cpp | Cast rcName to satisfy strlen’s parameter type in this context. |
| src/coreclr/utilcode/debug.cpp | Add UNREACHABLE() after RaiseFailFastException to satisfy noreturn analysis. |
| src/coreclr/nativeaot/Runtime/windows/PalMinWin.cpp | Remove redundant _T definition and fix include casing for NativeContext.h. |
| src/coreclr/nativeaot/Runtime/windows/CoffNativeCodeManager.h | Mark destructor virtual to address polymorphic-type destructor diagnostics. |
| src/coreclr/jit/utils.cpp | Fix signed/unsigned comparison by casting strBufferSize before comparing with bufferSize. |
Comments suppressed due to low confidence (1)
src/native/minipal/guid.c:76
- The
snprintfformat string uses%x/%02x/%04x(expectsunsigned intafter default promotions), but onlyData1is cast. The remaining arguments (Data2,Data3, andData4[i]) may still be passed asintdue to default promotions, which is undefined behavior and can still trigger clang-Wformatdiagnostics. Casting all arguments (or switching to<inttypes.h>macros) avoids both UB and remaining warnings.
int32_t nBytes = snprintf(guidString, len, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
(unsigned int)guid.Data1, guid.Data2, guid.Data3,
guid.Data4[0], guid.Data4[1],
guid.Data4[2], guid.Data4[3],
guid.Data4[4], guid.Data4[5],
guid.Data4[6], guid.Data4[7]);
jkoritzinsky
approved these changes
Jul 22, 2026
Member
Author
|
/ba-g widespread wasm infra issue that doesn't produce usable output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Out of curiosity I let copilot build clr.aot with clang. Most are signed/unsigned comparison mismatches that we treat as errors on Windows (
/we4018) and copilot matched it with-Wsign-compare.