Boost C++ Libraries: Ticket #8381: karma::uint_generator fails to compile in C++11 mode https://svn.boost.org/trac10/ticket/8381 <p> After the <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8361" title="#8361: Bugs: Linking problems with MSVC (closed: fixed)">#8361</a> ticket has been fixed (including my syntax fix in revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/83754" title="Fixed compilation on compilers with support for static_assert.">[83754]</a>) karma::uint_generator fails to compile on gcc 4.7.2 with the following error: </p> <pre class="wiki">In file included from ./boost/spirit/include/karma_uint.hpp:16:0, from karma_uint_gen.cpp:1: ./boost/spirit/home/karma/numeric/uint.hpp: In static member function ‘static bool boost::spirit::karma::any_uint_generator&lt;T, CharEncoding, Tag, Radix&gt;::generate(OutputIterator&amp;, Context&amp;, const Delimiter&amp;, boost::spirit::unused_type)’: ./boost/spirit/home/karma/numeric/uint.hpp:290:13: error: static assertion failed: uint_not_usable_without_attribute </pre><p> The attached code snippet demonstrates the problem if compiled with the following command. </p> <pre class="wiki">g++ -std=c++0x -I"." -c karma_uint_gen.cpp -o karma_uint_gen </pre><p> The code compiles fine if -std=c++0x is removed. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8381 Trac 1.4.3 Andrey Semashev Wed, 03 Apr 2013 20:16:44 GMT attachment set https://svn.boost.org/trac10/ticket/8381 https://svn.boost.org/trac10/ticket/8381 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">karma_uint_gen.cpp</span> </li> </ul> <p> The code snippet demonstrating the error. </p> Ticket Andrey Semashev Wed, 03 Apr 2013 20:28:41 GMT <link>https://svn.boost.org/trac10/ticket/8381#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8381#comment:1</guid> <description> <p> An additional observation. The code compiles on c++0x mode if native static_assert use is disabled in assert_msg.hpp. It looks like gcc performs the assertion failure when compiling any_uint_generator::generate because the compile time predicate is a constant false and does not depend on template parameters. For example, if I replace the line </p> <pre class="wiki">BOOST_SPIRIT_ASSERT_MSG(false, uint_not_usable_without_attribute, ()); </pre><p> with </p> <pre class="wiki">BOOST_SPIRIT_ASSERT_MSG((!is_same&lt; OutputIterator, OutputIterator &gt;::value), uint_not_usable_without_attribute, ()); </pre><p> the code compiles. I think this is a compiler bug, but a workaround is desired. Perhaps this any_uint_generator::generate overload should not be present in the first place? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Hartmut Kaiser</dc:creator> <pubDate>Thu, 04 Apr 2013 01:04:09 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8381#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8381#comment:2</guid> <description> <p> I'd appreciate if you were able to create a patch. I'd be glad to apply it. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Thu, 04 Apr 2013 03:09:49 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8381#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8381#comment:3</guid> <description> <p> I'm not sure what's the right solution for the problem. Should the method be removed? Or should the condition be tweaked? Or is there a better way? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Hartmut Kaiser</dc:creator> <pubDate>Thu, 04 Apr 2013 11:05:40 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8381#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8381#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8381#comment:3" title="Comment 3">andysem</a>: </p> <blockquote class="citation"> <p> I'm not sure what's the right solution for the problem. Should the method be removed? Or should the condition be tweaked? Or is there a better way? </p> </blockquote> <p> The main question is: why is this happening in the first place? Is it because gcc 4.7 in C++11 mode overeagerly instantiates this function without need? If this is the case, then we can't do anything than to wrap it into a proper preprocessor condition. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Thu, 04 Apr 2013 12:41:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8381#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8381#comment:5</guid> <description> <blockquote class="citation"> <p> The main question is: why is this happening in the first place? Is it because gcc 4.7 in C++11 mode overeagerly instantiates this function without need? </p> </blockquote> <p> It seems so, although I'm not sure it instantiates the whole function and not just static_assert. I didn't dig the standard to find out whether the compiler is supposed to behave that way (seems unlikely, though). </p> <blockquote class="citation"> <p> If this is the case, then we can't do anything than to wrap it into a proper preprocessor condition. </p> </blockquote> <p> Does the trick with is_same look like a reasonable solution to you? I searched the code, there are quite a few similar asserts on false constant scattered. I could replace such cases with a new macro with this trick, if it's ok with you. </p> <p> If not, then I'm afraid, the only option is to ban static_assert for gcc, which is unfortunate. </p> <p> PS: I took a closer look at the code and it looks like removing the offending functions can result in less concise error messages, so I'm not considering this option. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Hartmut Kaiser</dc:creator> <pubDate>Thu, 04 Apr 2013 14:29:59 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8381#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8381#comment:6</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8381#comment:5" title="Comment 5">andysem</a>: </p> <blockquote class="citation"> <blockquote class="citation"> <p> The main question is: why is this happening in the first place? Is it because gcc 4.7 in C++11 mode overeagerly instantiates this function without need? </p> </blockquote> <p> It seems so, although I'm not sure it instantiates the whole function and not just static_assert. I didn't dig the standard to find out whether the compiler is supposed to behave that way (seems unlikely, though). </p> <blockquote class="citation"> <p> If this is the case, then we can't do anything than to wrap it into a proper preprocessor condition. </p> </blockquote> <p> Does the trick with is_same look like a reasonable solution to you? I searched the code, there are quite a few similar asserts on false constant scattered. I could replace such cases with a new macro with this trick, if it's ok with you. </p> </blockquote> <p> Yeah sure. If that works, it's fine. </p> <blockquote class="citation"> <p> If not, then I'm afraid, the only option is to ban static_assert for gcc, which is unfortunate. </p> </blockquote> <p> Indeed, I agree. </p> <blockquote class="citation"> <p> PS: I took a closer look at the code and it looks like removing the offending functions can result in less concise error messages, so I'm not considering this option. </p> </blockquote> <p> *sigh* - there isn't much we could do otherwise if the solution you suggested does not work. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Sat, 06 Apr 2013 12:23:49 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/8381 https://svn.boost.org/trac10/ticket/8381 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">spirit_static_assert.patch</span> </li> </ul> <p> The patch fixes the problem by changing the assert condition. </p> Ticket Andrey Semashev Sat, 06 Apr 2013 12:26:03 GMT <link>https://svn.boost.org/trac10/ticket/8381#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8381#comment:7</guid> <description> <p> I attached the patch that resolves the original problem and also fixes the same issue in other places. I didn't test those other places though. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Hartmut Kaiser</dc:creator> <pubDate>Sat, 06 Apr 2013 14:36:42 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8381#comment:8 https://svn.boost.org/trac10/ticket/8381#comment:8 <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> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/83776" title="Fix #8381: karma::uint_generator fails to compile in C++11 mode">[83776]</a>) Fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8381" title="#8381: Bugs: karma::uint_generator fails to compile in C++11 mode (closed: fixed)">#8381</a>: karma::uint_generator fails to compile in C++11 mode </p> Ticket Andrey Semashev Tue, 09 Apr 2013 15:45:05 GMT <link>https://svn.boost.org/trac10/ticket/8381#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8381#comment:9</guid> <description> <p> Could you please merge it to release as well? The current assert_msg.hpp does not compile. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Hartmut Kaiser</dc:creator> <pubDate>Wed, 10 Apr 2013 22:51:21 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8381#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8381#comment:10</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8381#comment:9" title="Comment 9">andysem</a>: </p> <blockquote class="citation"> <p> Could you please merge it to release as well? The current assert_msg.hpp does not compile. </p> </blockquote> <p> Done. </p> </description> <category>Ticket</category> </item> </channel> </rss>