Boost C++ Libraries: Ticket #10723: UNINIT_CTOR(boost::​multi_index::​detail::​bidir_node_iterator<boost::​multi_index::​detail::​ordered_index_node<boost::​multi_index::​detail::​ordered_index_node<boost::​multi_index does not get initialised) https://svn.boost.org/trac10/ticket/10723 <p> In default constructor for the class "bidir_node_iterator " the private members are not initialized hence it shows a code quality error UNINIT_CTOR() as defined below :- </p> <p> template&lt;typename Node&gt; class bidir_node_iterator: </p> <blockquote> <p> public bidirectional_iterator_helper&lt; bidir_node_iterator&lt;Node&gt;, typename Node::value_type, std::ptrdiff_t, const typename Node::value_type*, const typename Node::value_type&amp;&gt; { </p> <blockquote> <p> public: </p> </blockquote> </blockquote> <p> <strong> Uninitialized pointer field (UNINIT_CTOR)2. uninit_member: Non-static class member "node" is not initialized in this constructor nor in any functions that it calls. </strong></p> <blockquote> <p> bidir_node_iterator(){}<strong> </strong></p> </blockquote> <p> * * private: </p> <blockquote> <p> Node* node; </p> </blockquote> <p> } </p> <p> <strong><strong>* This Private member has to be initialized in default constructor </strong>*</strong> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10723 Trac 1.4.3 Joaquín M López Muñoz Wed, 05 Nov 2014 07:40:03 GMT severity changed https://svn.boost.org/trac10/ticket/10723#comment:1 https://svn.boost.org/trac10/ticket/10723#comment:1 <ul> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Cosmetic</span> </li> </ul> <p> Added annotation at </p> <p> <a class="ext-link" href="https://github.com/boostorg/multi_index/commit/08fe6a360acf99e1732a54ef8b3114455f59116b"><span class="icon">​</span>https://github.com/boostorg/multi_index/commit/08fe6a360acf99e1732a54ef8b3114455f59116b</a> </p> <p> Could you please verify this shuts Coverity down? </p> Ticket Joaquín M López Muñoz Tue, 11 Nov 2014 19:47:20 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/10723#comment:2 https://svn.boost.org/trac10/ticket/10723#comment:2 <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">fixed</span> </li> </ul> Ticket anonymous Thu, 27 Aug 2015 18:12:30 GMT <link>https://svn.boost.org/trac10/ticket/10723#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10723#comment:3</guid> <description> <p> This isn't cosmetic: if the default constructor is used to create an instance, then the member variable "node" isn't initialized via the constructor =&gt; this can result in dereferencing an invalid pointer. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 27 Aug 2015 18:13:28 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10723#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10723#comment:4</guid> <description> <p> Either initialize "node" to NULL, or delete the constructor. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joaquín M López Muñoz</dc:creator> <pubDate>Thu, 27 Aug 2015 19:25:25 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10723#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10723#comment:5</guid> <description> <p> Hi anonymous, </p> <p> The default constructor is needed because it is permissible (and very useful) to default initialize an iterator, so we can't just omit this constructor. When default-initialized, the iterator has a <em>singular</em> value according to the C++ standard terminology in <strong>[iterator.requirements.general]/5</strong>. Dereferencing a singular value is undefined behavior, so the programmer is not allowed to do it regardless of whether the value of the pointer is null or not. My reluctance to initialize to null comes from the fact that we're introducing a run-time penalty in default construction (even if a negligible one) that, in the best of cases, will only expose undefined behavior more nicely. </p> <p> Anyway, is perhaps the annotation commited in </p> <p> <a class="ext-link" href="https://github.com/boostorg/multi_index/commit/08fe6a360acf99e1732a54ef8b3114455f59116b"><span class="icon">​</span>https://github.com/boostorg/multi_index/commit/08fe6a360acf99e1732a54ef8b3114455f59116b</a> </p> <p> not silencing the Coverity warning? </p> </description> <category>Ticket</category> </item> </channel> </rss>