Skip to content

Commit e12898c

Browse files
damyanpCopilotgithub-actions[bot]
authored
Fix signed/unsigned mismatch in LinAlgTests.cpp (#8336)
Change loop variables from int32_t to size_t to match the NumElements parameter type (size_t), fixing C4018 warnings treated as errors in x86 builds. Co-authored-by: Copilot <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 475e3cc commit e12898c

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

tools/clang/unittests/HLSLExec/LinAlgTests.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,21 +226,22 @@ static VariantCompType makeExpected(ComponentType CompType, size_t NumElements,
226226
switch (CompType) {
227227
case ComponentType::F32: {
228228
std::vector<float> Floats(NumElements);
229-
for (int32_t I = 0; I < NumElements; I++)
229+
for (size_t I = 0; I < NumElements; I++)
230230
Floats[I] = StartingVal + static_cast<float>(Increment ? I : 0);
231231
return Floats;
232232
}
233233
case ComponentType::I32: {
234234
DXASSERT(StartingVal < static_cast<float>(INT_MAX),
235235
"Value too large to cast to int32_t");
236236
std::vector<int32_t> Ints(NumElements);
237-
for (int32_t I = 0; I < NumElements; I++)
238-
Ints[I] = static_cast<int32_t>(StartingVal) + (Increment ? I : 0);
237+
for (size_t I = 0; I < NumElements; I++)
238+
Ints[I] = static_cast<int32_t>(StartingVal) +
239+
static_cast<int32_t>(Increment ? I : 0);
239240
return Ints;
240241
}
241242
case ComponentType::F16: {
242243
std::vector<HLSLHalf_t> Halfs(NumElements);
243-
for (int32_t I = 0; I < NumElements; I++) {
244+
for (size_t I = 0; I < NumElements; I++) {
244245
// Downcasting is safe here since HLSLHalf_t will clamp if F is too large.
245246
float F = StartingVal + static_cast<float>(Increment ? I : 0);
246247
Halfs[I] = HLSLHalf_t(F);

0 commit comments

Comments
 (0)