Boost C++ Libraries: Ticket #8152: operator_bool write access violation error in MSVC builds https://svn.boost.org/trac10/ticket/8152 <p> Using the unspecified_bool_type operator and the following pragma is causing write access violations with the Microsoft compiler: </p> <p> #pragma pointers_to_members(full_generality, virtual_inheritance) </p> <p> This behavior has been confirmed for boost_1_44_0 using an msvc90 build and for boost_1_53_0 using a msvc10 build. </p> <p> Here is the code that reproduces the error: </p> <pre class="wiki">//------- main.cpp --------- #pragma pointers_to_members(full_generality, virtual_inheritance) #include "TestClass.h" int main(int argc, char* argv[]) { IntPointer p(new int); bool isValid = p; TestClass test; test.setInt(p); return 0; } //------ TestClass.h ---------- #pragma once #include &lt;boost/shared_ptr.hpp&gt; typedef boost::shared_ptr&lt;int&gt; IntPointer; class TestClass { public: void setInt(IntPointer p); private: IntPointer m_p; }; //----- TestClass.cpp #include "TestClass.h" void TestClass::setInt(IntPointer p) { m_p = p; bool isValid = p; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8152 Trac 1.4.3 Ross MacGregor <rossmpublic.gmail.com> Mon, 25 Feb 2013 22:48:22 GMT <link>https://svn.boost.org/trac10/ticket/8152#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8152#comment:1</guid> <description> <p> I filed a bug with Microsoft as this does not seem to be directly related to the boost library. You can find a Zip attachment there with my crash test solution in for Visual Studio 2008. </p> <p> <a class="ext-link" href="https://connect.microsoft.com/VisualStudio/feedback/details/779972/c-pointers-to-members-pragma-generating-write-access-vilolation#tabs"><span class="icon">​</span>https://connect.microsoft.com/VisualStudio/feedback/details/779972/c-pointers-to-members-pragma-generating-write-access-vilolation#tabs</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ross MacGregor <rossmpublic.gmail.com></dc:creator> <pubDate>Fri, 01 Mar 2013 01:30:33 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8152#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8152#comment:2</guid> <description> <p> This is not a bug but an improper use of the pointer_to_members pragma. Info from the MS ticket: </p> <p> "Your code violates one definition rule in C++ standard. The pragma is used in main.cpp but not in <a class="missing wiki">TestClass</a>.cpp. This leads to two inconsistent definitions of the same '<a class="missing wiki">IntPointer</a>'. The code can run correctly if you move the pragma after #include directive because this eliminates the one definition rule violation." </p> <p> This issue may be closed. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Thu, 07 Mar 2013 08:21:27 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8152#comment:3 https://svn.boost.org/trac10/ticket/8152#comment:3 <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> Ticket