Fix #339: ChaiScript assumes a non-const object reference is an R-value (&&)#685
Conversation
…ng dispatch Cast_Helper_Inner<T&&> unconditionally called std::move() on the underlying object, even when the Boxed_Value held an lvalue reference (is_ref() == true). This caused T&& overloads to win over const T& overloads for objects returned by reference, silently moving from and destroying persistent objects. The fix rejects the T&& cast for reference Boxed_Values, allowing dispatch to fall through to the correct const T& overload. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@leftibot should we add explicit support for && types and allow moves for them implicitly? Sounds like potentially a lot of overhead for boxed_value but also seems necessary |
|
Good question. I dug through the relevant code to understand the scope of what this would entail. Current stateRight now, The existing What explicit
|
Automated fix by @leftibot.
What changed
Files
Closes #339
Triggered by @lefticus.