Skip to content

Conversation

lyriccoder
Copy link

In infer_shape, variables holding tensor element counts were declared as int/uint32_t and compared against fields from generic_param. This caused:

  1. Mixed signed/unsigned comparisons → implicit conversions may lead to incorrect results.
  2. Use of int/uint32_t for object sizes instead of the recommended size_t.

Importance

  • May cause logical errors when values exceed INT_MAX.
  • Potential risk of undefined behavior with very large tensors (>2G elements).

Related Standards:

  • MISRA C++ Rule 5-0-4: "An implicit integral conversion shall not change the signedness"
  • CERT C++ INT31-C: "Ensure that integer conversions do not result in lost or misinterpreted data"

Possible CWE Classification:
CWE-681: Incorrect Conversion between Numeric Types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant