(C++) shared\_ptr.hpp: Assertion failed: px != 0
February 24, 2017 · View on GitHub
(C++) shared_ptr.hpp: Assertion failed: px != 0
Full error message
Assertion failed: px != 0, file c:\my_files\include\boost\shared_ptr.hpp, line 253 Abnormal program termination
Cause
A boost::shared_ptr was used before initialization.
IDE: C++ Builder 6.0
Compiler: Borland BCC32.EXE version 6.0.10.157
Project type: Console Application
#include <boost/shared_ptr.hpp> int main() { boost::shared_ptr<Widget> w; //ERROR! Forgot to initialize w, should have written: //boost::shared_ptr<Widget> w(new Widget); w->mX; }
Solution
Initialize all boost::shared_ptrs.