Boost C++ Libraries: Ticket #8813: compiler errors with gcc in c++11 mode https://svn.boost.org/trac10/ticket/8813 <p> This is related to ticket: <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/7809"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/7809</a> </p> <p> It shows up in both boost 1.54 and 1.53. It is missing in 1.52. </p> <p> With g++ 4.7.0 (on SuSE 11, Linux 2.6.32.54, x86_64) using the options: </p> <p> -O2 -g -Iinclude/boost-1_54 -std=gnu++0x -Wstrict-overflow=0 -Wall </p> <p> I am getting: </p> <p> error: no type named 'unspecified_bool_type' in 'class boost::shared_array&lt;unsigned int&gt;' </p> <p> If I get rid of the option -std=gnu++0x then the error disappears. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8813 Trac 1.4.3 Peter Dimov Fri, 12 Jul 2013 08:36:19 GMT <link>https://svn.boost.org/trac10/ticket/8813#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8813#comment:1</guid> <description> <p> Where are you getting this error? </p> </description> <category>Ticket</category> </item> <item> <author>oleg.alexandrov@…</author> <pubDate>Sat, 13 Jul 2013 03:57:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8813#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8813#comment:2</guid> <description> <p> I am getting this error in compilation. I have a class which has a member function which does the following: </p> <blockquote> <p> typedef typename boost::shared_array&lt;T&gt;::unspecified_bool_type unspecified_bool_type; operator unspecified_bool_type() const { </p> <blockquote> <p> return m_data.size() &gt; 0; </p> </blockquote> <p> } </p> </blockquote> <p> As per above, the error is triggered only by Boost 1.53 and 1.54 and only if -std=gnu++0x is on. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Sat, 13 Jul 2013 07:30:09 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8813#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8813#comment:3</guid> <description> <p> <code>unspecified_bool_type</code> is not a documented part of <code>shared_array</code> and is not present when explicit operators are supported. You should either use </p> <pre class="wiki">#if !defined( BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS ) explicit operator bool () const { return m_data.size() &gt; 0; } #else // your current definition #endif </pre><p> or define your own <code>unspecified_bool_type</code>. </p> <p> Incidentally, your code above doesn't seem to compile, because <code>m_data.size() &gt; 0</code> returns a <code>bool</code>, which is not convertible to <code>unspecified_bool_type</code>. </p> </description> <category>Ticket</category> </item> <item> <author>oleg.alexandrov@…</author> <pubDate>Wed, 17 Jul 2013 15:41:57 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8813#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8813#comment:4</guid> <description> <p> I had more time to study this in more detail. The problem is real, but apparently it is also compiler version dependent. Here's the exact way to reproduce it. It shows up with gcc 4.7.0 but it does not show up with gcc 4.4.4. </p> <p> #include &lt;boost/shared_array.hpp&gt; </p> <p> template &lt;class T&gt; class <a class="missing wiki">MyClass</a>{ </p> <blockquote> <p> boost::shared_array&lt;T&gt; m_data; </p> </blockquote> <blockquote> <p> typedef typename boost::shared_array&lt;T&gt;::unspecified_bool_type unspecified_bool_type; operator unspecified_bool_type() const { </p> <blockquote> <p> return m_data; </p> </blockquote> <p> } </p> </blockquote> <p> public: </p> <blockquote> <p> int get(){ return 2; } </p> </blockquote> <p> }; </p> <p> int main(){ </p> <blockquote> <p> <a class="missing wiki">MyClass</a>&lt;int&gt; M; std::cout &lt;&lt; "value is " &lt;&lt; M.get() &lt;&lt; std::endl; return 0; </p> </blockquote> <p> } </p> <p> /shared/gcc/4.7.0/bin/g++ -c -std=gnu++0x -Iinclude/boost-1_54 bug.cc bug.cc: In instantiation of 'class <a class="missing wiki">MyClass</a>&lt;int&gt;': bug.cc:20:16: required from here bug.cc:7:66: error: no type named 'unspecified_bool_type' in 'class boost::shared_array&lt;int&gt;' </p> <p> If I remove the -std=gnu++0x or switch to gcc 4.4.4 then it works. </p> </description> <category>Ticket</category> </item> <item> <author>oleg.alexandrov@…</author> <pubDate>Wed, 17 Jul 2013 15:45:05 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8813#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8813#comment:5</guid> <description> <p> But I see your point above, presumably this code should never work, I guess what you are saying some compilers are more lenient than what they should be. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Wed, 11 Dec 2013 17:28:54 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8813#comment:6 https://svn.boost.org/trac10/ticket/8813#comment:6 <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