Fix(build): Correct maybe-uninitialized and range-loop-construct warnings - #26201
Merged
Conversation
edgchen1
approved these changes
Sep 29, 2025
edgchen1
left a comment
Contributor
There was a problem hiding this comment.
looks fine. FWIW, I think gsl::not_null is not very expensive to copy. in which build are these showing up as errors?
Contributor
Author
Linux GCC 15. Build command was: |
fs-eire
pushed a commit
that referenced
this pull request
Oct 24, 2025
…ings (#26201) This pull request addresses two build warnings that were treated as errors: 1. **`maybe-uninitialized` warning in `nchwc_transformer.cc`**: A `maybe-uninitialized` warning was triggered when accessing `nchwc_inputs[0]` without checking if `nchwc_inputs` was empty. This could lead to a crash if a binary node had no inputs. The fix adds a check to ensure the vector is not empty before accessing the first element. 2. **`range-loop-construct` warnings in `transformer_memcpy.cc`**: The compiler warned about creating copies of objects in range-based for loops. This was resolved by using references (`const auto&`) instead of copies (`const auto`) for the loop variables, which is more efficient. This fix was provided by an AI bot.
naomiOvad
pushed a commit
to naomiOvad/onnxruntime
that referenced
this pull request
Nov 2, 2025
…ings (microsoft#26201) This pull request addresses two build warnings that were treated as errors: 1. **`maybe-uninitialized` warning in `nchwc_transformer.cc`**: A `maybe-uninitialized` warning was triggered when accessing `nchwc_inputs[0]` without checking if `nchwc_inputs` was empty. This could lead to a crash if a binary node had no inputs. The fix adds a check to ensure the vector is not empty before accessing the first element. 2. **`range-loop-construct` warnings in `transformer_memcpy.cc`**: The compiler warned about creating copies of objects in range-based for loops. This was resolved by using references (`const auto&`) instead of copies (`const auto`) for the loop variables, which is more efficient. This fix was provided by an AI bot.
13 tasks
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request addresses two build warnings that were treated as errors:
maybe-uninitializedwarning innchwc_transformer.cc:A
maybe-uninitializedwarning was triggered when accessingnchwc_inputs[0]without checking ifnchwc_inputswas empty. This could lead to a crash if a binary node had no inputs. The fix adds a check to ensure the vector is not empty before accessing the first element.range-loop-constructwarnings intransformer_memcpy.cc:The compiler warned about creating copies of objects in range-based for loops. This was resolved by using references (
const auto&) instead of copies (const auto) for the loop variables, which is more efficient.This fix was provided by an AI bot.