Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) shared_ptr.hpp: Assertion failed: px != 0

 

Runtime error.

 

 

 

 

 

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.

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict