Open kahotv opened 1 year ago
put a -Werror -Wall -Werror -Wextra -Wpedantic -Weffc++
flags in your compile build .
-- If it can't compile such code, it is for a good reason
You cannot be ignoring initialization order , by doing so, A() :m_ch(m_ctx) {}
m_ch is initialized with uninitialized storage
using my_channel = concurrent_channel<void(asio::error_code, std::size_t)>; int main() { A a; a.show(); }
class A { public: A() :m_ch(m_ctx) {} void show() { printf("hello\n"); } private: // crash: my_channel m_ch; io_context m_ctx; // not crash: //io_context m_ctx; //my_channel m_ch; };