Skip to content

Fix cplusplus.Move: remove access to moved-from object in StrongType test#37923

Open
Copilot wants to merge 2 commits intomainfrom
copilot/fix-moved-from-object-issue-again
Open

Fix cplusplus.Move: remove access to moved-from object in StrongType test#37923
Copilot wants to merge 2 commits intomainfrom
copilot/fix-moved-from-object-issue-again

Conversation

Copy link
Contributor

Copilot AI commented Feb 16, 2026

Ticket

Link to Github Issue

Problem description

Clang Static Analyzer flags cplusplus.Move violation in tt_stl/tests/test_strong_type.cpp:78 — test accessed a moved-from StrongType<unique_ptr<int>> to verify the wrapped pointer was null. Accessing moved-from objects is undefined behavior per C++ standard.

What's changed

Removed assertion that dereferenced the moved-from object. Test now only validates the moved-to object contains expected value, which sufficiently verifies move semantics without UB.

Before:

MoveOnlyType to = std::move(from);
// NOLINTNEXTLINE(bugprone-use-after-move)
EXPECT_THAT(*from, IsNull());  // UB: accessing moved-from object
EXPECT_EQ(**to, 42);

After:

MoveOnlyType to = std::move(from);
EXPECT_EQ(**to, 42);  // Sufficient to validate move succeeded

Checklist

  • All post-commit tests
  • Blackhole Post commit
  • cpp-unit-tests
  • New/Existing tests provide coverage for changes

Model tests

If your changes cover model-related code, you should run tests corresponding to affected models and platforms (Single card, T3K, Galaxy). "Choose your pipeline" workflows facilitate running multiple kinds of tests in a single run. Each offers models-mandatory and models-extended presets.
The former includes a minimal set of tests, to be run always. The latter extends that with additional ones - use your best judgement in deciding which is the most appropriate for your PR.

Original prompt

Fix this Clang Static Analyzer issue:

  • cplusplus.Move in tt_stl/tests/test_strong_type.cpp:78 — Method called on moved-from object 'from'

Verify it's a real issue, apply minimal fix, follow coding standards.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: blozano-tt <181790211+blozano-tt@users.noreply.github.com>
@blozano-tt blozano-tt added the copilot-autofix PRs automatically created by Copilot to fix ClangSA issues label Feb 16, 2026
@blozano-tt blozano-tt marked this pull request as ready for review February 16, 2026 06:29
Copilot AI review requested due to automatic review settings February 16, 2026 06:29
@blozano-tt blozano-tt requested review from a team and akerteszTT as code owners February 16, 2026 06:29
Copilot AI changed the title [WIP] Fix Clang Static Analyzer issue for moved-from object Fix cplusplus.Move: remove access to moved-from object in StrongType test Feb 16, 2026
Copilot AI requested a review from blozano-tt February 16, 2026 06:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a Clang Static Analyzer issue where a moved-from std::unique_ptr wrapped in StrongType was being accessed, which is undefined behavior. The fix removes the problematic assertion that attempted to verify the moved-from object's state, keeping only the verification of the moved-to object.

Changes:

  • Removed two lines that accessed a moved-from StrongType<std::unique_ptr<int>> object, eliminating undefined behavior
  • The test now correctly validates only the moved-to object contains the expected value

@blozano-tt
Copy link
Contributor

I agree with copilot, clang static analyzer, and clang-tidy.

Let’s just delete this code.

@blozano-tt
Copy link
Contributor

/codeowners ping

@tenstorrent-github-bot
Copy link

CodeOwners Group Analysis

This PR requires approval from one member of each of the following groups:

Summary: 1 pending groups, 0 approved groups

Group Information:

Note: At least one approval from each group is sufficient.

@tenstorrent-github-bot
Copy link

Hi Audrey Kertesz (@akerteszTT), Artem Yerofieiev (@ayerofieiev-tt), this PR Fix cplusplus.Move: remove access to moved-from object in StrongType test by Copilot (@Copilot) needs your approval/review to merge this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot-autofix PRs automatically created by Copilot to fix ClangSA issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants