Boost C++ Libraries: Ticket #4369: function::function_base potential uninitialized data member https://svn.boost.org/trac10/ticket/4369 <p> When running the Klocwork static code analysis tool on some code that uses Boost, Klocwork reported the following potential issue in Boost.Function (note that this is for boost 1_36_0, but the latest trunk code appears to have the same issue): </p> <hr /> <p> 'this-&gt;functor.const_obj_ptr' is not initialized in this constructor.<br /> function_base.hpp:576: 'this-&gt;functor.const_obj_ptr' is used, but is uninitialized.<br /> </p> <pre class="wiki">class function_base { public: function_base() : vtable(0) { } ... public: // should be protected, but GCC 2.95.3 will fail to allow access detail::function::vtable_base* vtable; mutable detail::function::function_buffer functor; }; </pre><hr /> <p> A similar error is reported for each field in the functor data member (a function_buffer union). Wouldn't it be appropriate to initialize the functor data member to a default value, as is done with the vtable data member? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4369 Trac 1.4.3 Steven Watanabe Sun, 11 Jul 2010 02:06:51 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4369#comment:1 https://svn.boost.org/trac10/ticket/4369#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> functor can never be used without being initialized. Initializing vtable to 0 indicates that the function is empty, so functor is unused. </p> Ticket