Skip to content

Fix(build): Correct maybe-uninitialized and range-loop-construct warnings - #26201

Merged
snnn merged 1 commit into
mainfrom
fix/build-errors
Sep 30, 2025
Merged

Fix(build): Correct maybe-uninitialized and range-loop-construct warnings#26201
snnn merged 1 commit into
mainfrom
fix/build-errors

Conversation

@snnn

@snnn snnn commented Sep 29, 2025

Copy link
Copy Markdown
Contributor

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.

@snnn
snnn requested a review from edgchen1 September 29, 2025 20:32

@edgchen1 edgchen1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks fine. FWIW, I think gsl::not_null is not very expensive to copy. in which build are these showing up as errors?

@snnn

snnn commented Sep 29, 2025

Copy link
Copy Markdown
Contributor Author

in which build are these showing up as errors?

Linux GCC 15. Build command was:

python3 tools/ci_build/build.py --update --build --build_dir b2 --skip_submodule_sync --parallel 16  --build_shared_lib --config Release --cmake_extra_defines protobuf_WITH_ZLIB=OFF

@snnn
snnn merged commit 8ebd0bf into main Sep 30, 2025
113 of 116 checks passed
@snnn
snnn deleted the fix/build-errors branch September 30, 2025 04:19
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.
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.

2 participants