Skip to content

Commit

Permalink
Prevent exception in generic noexcept function.
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannier committed Jan 9, 2025
1 parent 3eda5e3 commit 7daf250
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions hilti/runtime/include/types/reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,13 @@ class ValueReference {
*/
ValueReference& operator=(ValueReference&& other) noexcept {
if ( &other != this ) {
// We can't move the actual value as other references may be
// referring to it.
*_get() = *other._get();

// Some implementations for `std::variant` do not have a `noexpect`
// move assignment operator.
// Not all types wrapped in a `ValueReference` might have a
// `noexcept` (move) assignment operator.
try {
// We can't move the actual value as other references may be
// referring to it.
*_get() = *other._get();

other._ptr = nullptr;
} catch ( ... ) {
cannot_be_reached();
Expand Down

0 comments on commit 7daf250

Please sign in to comment.