Fix reference to temporary that has gone out of scope#8866
Fix reference to temporary that has gone out of scope#8866kroening merged 1 commit intodiffblue:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes undefined behavior in unit tests caused by passing a temporary irep_idt{} into constructors that (directly or indirectly) store references, ensuring the referenced object outlives the constructed test fixtures.
Changes:
- Introduce a named
empty_language_modevariable to give the language-mode argument a stable lifetime. - Replace uses of
irep_idt{}temporaries with the named variable in affected test constructions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| unit/goto-symex/symex_assign.cpp | Avoids dangling reference by binding language-mode to a local variable reused across multiple constructions. |
| unit/goto-symex/goto_symex_state.cpp | Same lifetime fix for goto_symex_statet construction in state unit test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8866 +/- ##
========================================
Coverage 80.00% 80.01%
========================================
Files 1703 1703
Lines 188397 188397
Branches 73 73
========================================
+ Hits 150736 150742 +6
+ Misses 37661 37655 -6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
May I suggest changing the reference |
Store language_mode by value instead of by reference in goto_symex_statet. The copy is cheap (irep_idt is an interned string index) and eliminates the dangling-reference problem at the root: the class now owns its data, so callers need not worry about the lifetime of the argument. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
c3e4582 to
f279121
Compare
Thanks, done. Updated the commit & PR description accordingly. |
Store language_mode by value instead of by reference in goto_symex_statet. The copy is cheap (irep_idt is an interned string index) and eliminates the dangling-reference problem at the root: the class now owns its data, so callers need not worry about the lifetime of the argument.
Co-authored-by: Kiro kiro-agent@users.noreply.github.com