bkietz commented on code in PR #44493:
URL: https://github.com/apache/arrow/pull/44493#discussion_r1828137929
##########
cpp/src/arrow/status.cc:
##########
@@ -160,7 +163,11 @@ void Status::AddContextLine(const char* filename, int
line, const char* expr) {
ARROW_CHECK(!ok()) << "Cannot add context line to ok status";
std::stringstream ss;
ss << "\n" << filename << ":" << line << " " << expr;
- state_->msg += ss.str();
+ if (state_->is_constant) {
+ // We can't add context lines to a StatusConstant's state, so copy it now
+ state_ = new State{code(), message(), detail()};
+ }
+ const_cast<State*>(state_)->msg += ss.str();
Review Comment:
I did this to satisfy myself that this line was the only place we ever
mutate `state_`. I can remove the `const` now that I'm sure, but... since this
line *is* the only place we ever mutate `state_`, I thought it'd be better to
leave it so that in the future if we add another mutation we won't forget to
CopyOnWrite any constants
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]