Skip to content

Conversation

@CoTinker
Copy link
Contributor

@CoTinker CoTinker commented Jul 3, 2025

warning: comparison of unsigned expression in ‘< 0’ is always false [-Wtype-limits]

size_t is unsigned and always non-negative, whereas getInt() returns a signless int64_t. To ensure type compatibility and eliminate the warning, dynamicOptionIdx should be changed to int64_t.

```
warning: comparison of unsigned expression in ‘< 0’ is always false [-Wtype-limits]
```
`size_t` is unsigned and always non-negative, whereas `getInt()` returns a
signless `int64_t`. To ensure type compatibility and eliminate the warning,
`dynamicOptionIdx` should be changed to `int64_t`.
@CoTinker CoTinker requested a review from rolfmorel July 3, 2025 14:12
@llvmbot llvmbot added the mlir label Jul 3, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 3, 2025

@llvm/pr-subscribers-mlir

Author: Longsheng Mou (CoTinker)

Changes
warning: comparison of unsigned expression in ‘&lt; 0’ is always false [-Wtype-limits]

size_t is unsigned and always non-negative, whereas getInt() returns a signless int64_t. To ensure type compatibility and eliminate the warning, dynamicOptionIdx should be changed to int64_t.


Full diff: https://github.com/llvm/llvm-project/pull/146898.diff

1 Files Affected:

  • (modified) mlir/lib/Dialect/Transform/IR/TransformOps.cpp (+5-4)
diff --git a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
index bb9bdd70625e4..0db0317461c03 100644
--- a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
+++ b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
@@ -799,8 +799,8 @@ transform::ApplyRegisteredPassOp::apply(transform::TransformRewriter &rewriter,
     if (auto paramOperand = dyn_cast<transform::ParamOperandAttr>(valueAttr)) {
       // The corresponding value attribute(s) is/are passed in via a param.
       // Obtain the param-operand via its specified index.
-      size_t dynamicOptionIdx = paramOperand.getIndex().getInt();
-      assert(dynamicOptionIdx < dynamicOptions.size() &&
+      int64_t dynamicOptionIdx = paramOperand.getIndex().getInt();
+      assert(dynamicOptionIdx < static_cast<int64_t>(dynamicOptions.size()) &&
              "the number of ParamOperandAttrs in the options DictionaryAttr"
              "should be the same as the number of options passed as params");
       ArrayRef<Attribute> attrsAssociatedToParam =
@@ -1015,8 +1015,9 @@ LogicalResult transform::ApplyRegisteredPassOp::verify() {
   std::function<LogicalResult(Attribute)> checkOptionValue =
       [&](Attribute valueAttr) -> LogicalResult {
     if (auto paramOperand = dyn_cast<transform::ParamOperandAttr>(valueAttr)) {
-      size_t dynamicOptionIdx = paramOperand.getIndex().getInt();
-      if (dynamicOptionIdx < 0 || dynamicOptionIdx >= dynamicOptions.size())
+      int64_t dynamicOptionIdx = paramOperand.getIndex().getInt();
+      if (dynamicOptionIdx < 0 ||
+          dynamicOptionIdx >= static_cast<int64_t>(dynamicOptions.size()))
         return emitOpError()
                << "dynamic option index " << dynamicOptionIdx
                << " is out of bounds for the number of dynamic options: "

@CoTinker CoTinker merged commit 48e89a8 into llvm:main Jul 4, 2025
11 checks passed
@CoTinker CoTinker deleted the fix_Wtype-limits branch July 4, 2025 01:31
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 4, 2025

LLVM Buildbot has detected a new failure on builder flang-arm64-windows-msvc running on linaro-armv8-windows-msvc-01 while building mlir at step 7 "test-build-unified-tree-check-flang".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/207/builds/3351

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-flang) failure: test (failure)
******************** TEST 'Flang :: Lower/OpenMP/wsloop-reduction-logical-kinds.f90' FAILED ********************
Exit Code: 2

Command Output (stdout):
--
# RUN: at line 1
c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe -fc1 -emit-hlfir -fopenmp -o - C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\flang\test\Lower\OpenMP\wsloop-reduction-logical-kinds.f90 | c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\filecheck.exe C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\flang\test\Lower\OpenMP\wsloop-reduction-logical-kinds.f90
# executed command: 'c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe' -fc1 -emit-hlfir -fopenmp -o - 'C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\flang\test\Lower\OpenMP\wsloop-reduction-logical-kinds.f90'
# .---command stderr------------
# | PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
# | Stack dump:
# | 0.	Program arguments: c:\\users\\tcwg\\llvm-worker\\flang-arm64-windows-msvc\\build\\bin\\flang.exe -fc1 -emit-hlfir -fopenmp -o - C:\\Users\\tcwg\\llvm-worker\\flang-arm64-windows-msvc\\llvm-project\\flang\\test\\Lower\\OpenMP\\wsloop-reduction-logical-kinds.f90
# | Exception Code: 0xC0000005
# |  #0 0x00007ff78ded1c74 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x1a91c74)
# |  #1 0x00007ff78decf95c (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x1a8f95c)
# |  #2 0x00007ff78decd7f0 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x1a8d7f0)
# |  #3 0x00007ff78ded3504 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x1a93504)
# |  #4 0x00007ff78decd358 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x1a8d358)
# |  #5 0x00007ff78ccec7b8 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x8ac7b8)
# |  #6 0x00007ff78cd35c18 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x8f5c18)
# |  #7 0x00007ff78cddf05c (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x99f05c)
# |  #8 0x00007ff78cd35054 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x8f5054)
# |  #9 0x00007ff78c4d8ac0 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x98ac0)
# | #10 0x00007ff78c4eea88 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0xaea88)
# | #11 0x00007ff78c4434e8 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x34e8)
# | #12 0x00007ff78c4420a4 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x20a4)
# | #13 0x00007ff7910fe2e8 mlir::detail::FallbackTypeIDResolver::registerImplicitTypeID(class llvm::StringRef) (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x4cbe2e8)
# | #14 0xce3ffff7910fe384
# `-----------------------------
# error: command failed with exit status: 0xc0000005
# executed command: 'c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\filecheck.exe' 'C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\flang\test\Lower\OpenMP\wsloop-reduction-logical-kinds.f90'
# .---command stderr------------
# | FileCheck error: '<stdin>' is empty.
# | FileCheck command line:  c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\filecheck.exe C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\flang\test\Lower\OpenMP\wsloop-reduction-logical-kinds.f90
# `-----------------------------
# error: command failed with exit status: 2

--

********************


@CoTinker CoTinker restored the fix_Wtype-limits branch July 17, 2025 13:18
@CoTinker CoTinker deleted the fix_Wtype-limits branch July 21, 2025 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants