Skip to content

Fix std::max type mismatch for size_t Rank (portable across platforms)#6734

Merged
copybara-service[bot] merged 1 commit into
google-ai-edge:mainfrom
weidu-tpvision:fix-std-max-size-t
Apr 13, 2026
Merged

Fix std::max type mismatch for size_t Rank (portable across platforms)#6734
copybara-service[bot] merged 1 commit into
google-ai-edge:mainfrom
weidu-tpvision:fix-std-max-size-t

Conversation

@weidu-tpvision
Copy link
Copy Markdown
Contributor

… such as armv7-a in 32 bits)

Fix type mismatch in std::max for size_t Rank

The current code uses:
std::max(1lu, Rank)

This can cause template deduction issues because:

  • 1lu is unsigned long
  • Rank is size_t

These types are not guaranteed to match across platforms, which may lead to compilation errors.

This change replaces it with:
std::max(static_cast<size_t>(1), Rank)

This ensures both arguments have the same type and makes
the code portable across platforms.

No functional change intended.

More specifically, I got an error of type mismatch when build for armv7-a and I got it work with
std::max(1u, Rank),
but then it will have problem with armv8. ChatGPT suggested static_cast to size_t.

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 3, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@snnn snnn added the CLA:yes label Apr 3, 2026
@copybara-service copybara-service Bot merged commit 5492ef4 into google-ai-edge:main Apr 13, 2026
6 of 7 checks passed
@snnn
Copy link
Copy Markdown
Contributor

snnn commented Apr 13, 2026

Thank you!

@weidu-tpvision
Copy link
Copy Markdown
Contributor Author

My second contribution to open source! The first one is for onnxruntime!

@weidu-tpvision weidu-tpvision deleted the fix-std-max-size-t branch April 14, 2026 08:23
@snnn
Copy link
Copy Markdown
Contributor

snnn commented Apr 14, 2026

Haha, I made a lot of changes to onnxruntime as well.

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.

2 participants