Skip to content

Commit d688e75

Browse files
liyinsgyin.li
andauthored
Fix compile issue when the linking project is using C++23 (#3180)
The root cause is unique_ptr has constexpr destructor since C++23 libcxx/include/__memory/unique_ptr.h:75:19: error: invalid application of 'sizeof' to an incomplete type 'brpc::RedisCommandHandler' 75 | static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type"); | ^~~~~~~~~~~ libcxx/include/__memory/unique_ptr.h:290:7: note: in instantiation of member function 'std::default_delete<brpc::RedisCommandHandler>::operator()' requested here 290 | __deleter_(__tmp); | ^ libcxx/include/__memory/unique_ptr.h:259:71: note: in instantiation of member function 'std::unique_ptr<brpc::RedisCommandHandler>::reset' requested here 259 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); } | ^ src/brpc/redis.h:220:14: note: in instantiation of member function 'std::unique_ptr<brpc::RedisCommandHandler>::~unique_ptr' requested here 220 | explicit RedisConnContext(const RedisService* rs) | ^ src/brpc/redis.h:190:7: note: forward declaration of 'brpc::RedisCommandHandler' 190 | class RedisCommandHandler; Co-authored-by: yin.li <[email protected]>
1 parent 9f4947c commit d688e75

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/brpc/redis.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ bool RedisRequest::AddCommand(const butil::StringPiece& command) {
101101
CHECK(st.ok()) << st;
102102
_has_error = true;
103103
return false;
104-
}
104+
}
105105
}
106106

107-
bool RedisRequest::AddCommandByComponents(const butil::StringPiece* components,
107+
bool RedisRequest::AddCommandByComponents(const butil::StringPiece* components,
108108
size_t n) {
109109
if (_has_error) {
110110
return false;
@@ -117,7 +117,7 @@ bool RedisRequest::AddCommandByComponents(const butil::StringPiece* components,
117117
CHECK(st.ok()) << st;
118118
_has_error = true;
119119
return false;
120-
}
120+
}
121121
}
122122

123123
bool RedisRequest::AddCommandWithArgs(const char* fmt, ...) {
@@ -356,7 +356,7 @@ bool RedisService::AddCommandHandler(const std::string& name, RedisCommandHandle
356356
_command_map[lcname] = handler;
357357
return true;
358358
}
359-
359+
360360
RedisCommandHandler* RedisService::FindCommandHandler(const butil::StringPiece& name) const {
361361
auto it = _command_map.find(name.as_string());
362362
if (it != _command_map.end()) {
@@ -371,6 +371,11 @@ RedisCommandHandler* RedisCommandHandler::NewTransactionHandler() {
371371
}
372372

373373
// ========== impl of RedisConnContext ==========
374+
RedisConnContext::RedisConnContext(const RedisService* rs)
375+
: redis_service(rs)
376+
, batched_size(0)
377+
, session(nullptr) {}
378+
374379
RedisConnContext::~RedisConnContext() { }
375380

376381
void RedisConnContext::Destroy() {

src/brpc/redis.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,7 @@ class RedisCommandParser;
217217
// This class is as parsing_context in socket.
218218
class RedisConnContext : public Destroyable {
219219
public:
220-
explicit RedisConnContext(const RedisService* rs)
221-
: redis_service(rs)
222-
, batched_size(0)
223-
, session(nullptr) {}
220+
explicit RedisConnContext(const RedisService* rs);
224221

225222
~RedisConnContext();
226223
// @Destroyable

0 commit comments

Comments
 (0)