Boost C++ Libraries: Ticket #2069: #elif behaviour in gcc 4.4 https://svn.boost.org/trac10/ticket/2069 <p> hi all, </p> <p> currently, the mpl header do not compile with gcc-4.4 </p> <p> a small patch is attached </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2069 Trac 1.4.3 tim blechmann <tim@…> Fri, 04 Jul 2008 11:58:59 GMT attachment set https://svn.boost.org/trac10/ticket/2069 https://svn.boost.org/trac10/ticket/2069 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_mpl_gcc-4_4.patch</span> </li> </ul> Ticket Daniel James Sat, 12 Jul 2008 12:54:03 GMT attachment set https://svn.boost.org/trac10/ticket/2069 https://svn.boost.org/trac10/ticket/2069 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">mpl.patch</span> </li> </ul> <p> A better patch for this problem. </p> Ticket Daniel James Sat, 12 Jul 2008 13:24:36 GMT milestone changed; cc set https://svn.boost.org/trac10/ticket/2069#comment:1 https://svn.boost.org/trac10/ticket/2069#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">daniel@…</span> added </li> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.36.0</span> → <span class="trac-field-new">Boost 1.37.0</span> </li> </ul> <p> The patch I just attached is more complete and calls BOOST_PP_ITERATION_DEPTH correctly. But this is a larger problem, so I've also written to the mailing list. </p> <p> (I also changed the milestone to 1.37 because we shouldn't accept patches for unreleased compilers at this late stage). </p> Ticket tim blechmann <tim@…> Wed, 20 Aug 2008 08:47:11 GMT attachment set https://svn.boost.org/trac10/ticket/2069 https://svn.boost.org/trac10/ticket/2069 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">0001-boost.mpl-gcc-4.4-fixes.patch</span> </li> </ul> <p> patch against boost-1.36.0 </p> Ticket Daniel James Wed, 20 Aug 2008 19:53:32 GMT owner, component, summary changed https://svn.boost.org/trac10/ticket/2069#comment:2 https://svn.boost.org/trac10/ticket/2069#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Aleksey Gurtovoy</span> to <span class="trac-author">No-Maintainer</span> </li> <li><strong>component</strong> <span class="trac-field-old">mpl</span> → <span class="trac-field-new">preprocessor</span> </li> <li><strong>summary</strong> <span class="trac-field-old">compile mpl with gcc-4.4</span> → <span class="trac-field-new">#elif behaviour in gcc 4.4</span> </li> </ul> <p> The following is copied from: <a class="ext-link" href="http://lists.boost.org/Archives/boost/2008/07/139765.php"><span class="icon">​</span>http://lists.boost.org/Archives/boost/2008/07/139765.php</a> </p> <p> A recent change to the development version of the gcc preprocessor changes the way it processes '#elif' directives and breaks a common use of the preprocessor library. We've already had reports of this causing problems in MPL, and it might also affect: variant, function_types, python, fusion, xpressive and phoenix. Details of the change are at: </p> <p> <a class="ext-link" href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36320"><span class="icon">​</span>http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36320</a> </p> <p> With this change, the argument to an '#elif' directive is processed even if a previous '#if'/'#elif' directive was true. This causes the example use of BOOST_PP_ITERATION_DEPTH to break: </p> <p> <a href="http://www.boost.org/doc/libs/1_35_0/libs/preprocessor/doc/ref/iteration_depth.html">http://www.boost.org/doc/libs/1_35_0/libs/preprocessor/doc/ref/iteration_depth.html</a> </p> <p> In this example, the first time the header is included, BOOST_PP_ITERATION_DEPTH is not yet defined, so it causes the develoment gcc to fail when the #elif directives are evaluated (which are skipped with existing versions, because the first #if directive evaluates to true). </p> <p> Looking at the standard, I think their interpretation is correct (although I'm not familiar with it and could be missing something) but it isn't clear that this was the intent of the authors. Any opinions on this? </p> <p> I think it's quite easy to work around, we can replace: </p> <pre class="wiki">#if !BOOST_PP_IS_ITERATING // .... #elif BOOST_PP_ITERATION_DEPTH() == 1 // .... #elif BOOST_PP_ITERATION_DEPTH() == 2 // .... #endif </pre><p> with: </p> <pre class="wiki">#if !BOOST_PP_IS_ITERATING // .... #else # if BOOST_PP_ITERATION_DEPTH() == 1 // .... # elif BOOST_PP_ITERATION_DEPTH() == 2 // .... # endif #endif </pre><p> So that the calls to BOOST_PP_ITERATION_DEPTH are skipped - or we could just include the necessary header before including the file. But it does seem a pity that any code which uses this technique might need to be changed for gcc 4.4. We should probably write to them about this (it doesn't look like they realised this would be a problem), but I'm writing here first in case anyone has any ideas. </p> Ticket Ralf W. Grosse-Kunstleve Mon, 15 Sep 2008 16:26:47 GMT cc changed https://svn.boost.org/trac10/ticket/2069#comment:3 https://svn.boost.org/trac10/ticket/2069#comment:3 <ul> <li><strong>cc</strong> <span class="trac-author">rwgk@…</span> added </li> </ul> Ticket Ralf W. Grosse-Kunstleve Mon, 15 Sep 2008 16:31:01 GMT <link>https://svn.boost.org/trac10/ticket/2069#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2069#comment:4</guid> <description> <p> Is anyone working on this issue? </p> <p> gcc 4.4 is in stage 3 now, and it looks like the new behavior will make it into the release. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Daniel James</dc:creator> <pubDate>Mon, 15 Sep 2008 18:46:27 GMT</pubDate> <title>owner, status changed https://svn.boost.org/trac10/ticket/2069#comment:5 https://svn.boost.org/trac10/ticket/2069#comment:5 <ul> <li><strong>owner</strong> changed from <span class="trac-author">No-Maintainer</span> to <span class="trac-author">Daniel James</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> No, no one's working on it. Someone said they were going to write to Paul Mensonides but I guess that didn't work out, so it looks like it's up to me. </p> Ticket Ralf W. Grosse-Kunstleve Mon, 15 Sep 2008 19:04:51 GMT <link>https://svn.boost.org/trac10/ticket/2069#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2069#comment:6</guid> <description> <p> I just wrote a small Python script to do most of the work automatically. With this I got Boost.Python to compile with gcc 4.4. The script and the diffs against the current trunk are here: </p> <blockquote> <p> <a class="ext-link" href="http://cci.lbl.gov/~rwgk/tmp/gcc44_boost/"><span class="icon">​</span>http://cci.lbl.gov/~rwgk/tmp/gcc44_boost/</a> </p> </blockquote> <p> Files fixit.py and diffs_r48789_2008_09_15_1159. </p> <p> I'll run these changes through our in-house multi-platform build+testing procedure. </p> <p> I'm not setup for running the standard boost unit tests, to exercise the changes not used by Boost.Python. Help with this would be great. </p> <p> Ralf </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Daniel James</dc:creator> <pubDate>Mon, 15 Sep 2008 20:05:02 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2069#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2069#comment:7</guid> <description> <p> Oh very clever. I wish I'd seen that you'd done that before doing some of them manually. I'm feeling stupid now. </p> <p> Your patch looks good. To be picky, the comments are a bit mismatched - you've put 'gcc 4.4 compatability' on the <code>#else</code> from the outer if statement and the <code>#endif</code> from the inner statement. That could be confusing and it should be easy to fix. I'd suggest something like: </p> <pre class="wiki">// For gcc 4.4 compatability, we must include the // BOOST_PP_ITERATION_DEPTH test inside an #else clause. #else // BOOST_PP_IS_ITERATING #if BOOST_PP_ITERATION_DEPTH() == 1 </pre><p> and at the end: </p> <pre class="wiki">#endif // BOOST_PP_ITERATION_DEPTH() </pre><p> But feel free to do it however you want. </p> <p> I'm not set up for testing Boost.Python, but I can test the other libraries - so it's very convenient can you can test it. Can you create a ticket for just the python changes (include a link to this ticket, ie. <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2069" title="#2069: Bugs: #elif behaviour in gcc 4.4 (closed: fixed)">#2069</a>), and I'll deal with the other libraries. function_types is a bit of a problem as I'm getting failures on gcc 4.3 and the code to be changed looks a little odd already. </p> <p> Thanks for your help. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ralf W. Grosse-Kunstleve</dc:creator> <pubDate>Mon, 15 Sep 2008 21:55:25 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2069#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2069#comment:8</guid> <description> <p> OK, I changed the Python script according to your suggestions, and I'm only applying the script to the mpl and python subdirectories. (I need the mpl patches for Boost.Python). I won't do anything with the other files since I'm not setup for the tests, but there aren't very many. Suggestion: </p> <ul><li>I try out the mpl and python fixes in our multi-platform build. </li><li>I pass them by David Abrahams for review. </li><li>Then I check them in. </li><li>Once that is settled (in a day or two) you work on the rest. </li></ul><p> How does that sound? (You can easily run the script yourself to do most of the legwork for the rest. Let me know if you need more information.) Ralf </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Daniel James</dc:creator> <pubDate>Mon, 15 Sep 2008 22:08:36 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2069#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2069#comment:9</guid> <description> <p> That's great, although I might not wait to deal with the other libraries. Thanks again. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ralf W. Grosse-Kunstleve</dc:creator> <pubDate>Tue, 16 Sep 2008 02:11:42 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2069#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2069#comment:10</guid> <description> <p> In the meantime, I ran our multi-platform build+test with the modified boost sources, and there are no errors. I wrote David and Aleksey, pointing them to the diffs: </p> <p> <a class="ext-link" href="http://cci.lbl.gov/~rwgk/tmp/gcc44_boost/diffs_r48790_mpl_python_2008_09_15_1456"><span class="icon">​</span>http://cci.lbl.gov/~rwgk/tmp/gcc44_boost/diffs_r48790_mpl_python_2008_09_15_1456</a> </p> <p> I'll wait until tomorrow afternoon for feedback, although it seems highly unlikely that there's something wrong with the diffs. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ralf W. Grosse-Kunstleve</dc:creator> <pubDate>Thu, 25 Sep 2008 04:53:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2069#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2069#comment:11</guid> <description> <p> No feedback from David or Aleksey... </p> <p> I went ahead and checked in my patches: </p> <hr /> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/48960" title="boost/python, boost/mpl: gcc 4.4 compatibility (see ...">r48960</a> | rwgk | 2008-09-24 21:49:24 -0700 (Wed, 24 Sep 2008) | 1 line </p> <p> boost/python, boost/mpl: gcc 4.4 compatibility (see <a class="ext-link" href="http://svn.boost.org/trac/bo"><span class="icon">​</span>http://svn.boost.org/trac/bo</a> ost/ticket/2069) </p> <hr /> </description> <category>Ticket</category> </item> <item> <dc:creator>Daniel James</dc:creator> <pubDate>Wed, 01 Oct 2008 12:07:26 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2069#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2069#comment:12</guid> <description> <p> Sorry, I've been very slack. Here are the patches I've submitted: <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2375" title="#2375: Bugs: Fix gcc 4.4 preprocessor problem in Function Types (closed: invalid)">#2375</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2376" title="#2376: Patches: Fix gcc 4.4 preprocessor problem in Fusion (closed: invalid)">#2376</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2377" title="#2377: Bugs: Fix gcc 4.4 preprocessor problem in Proto. (closed: fixed)">#2377</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2378" title="#2378: Patches: Fix gcc 4.4 preprocessor problem in Phoenix (closed: invalid)">#2378</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2379" title="#2379: Patches: Fix gcc 4.4 preprocessor problem in Variant (closed: invalid)">#2379</a>. </p> <p> I'll change the preprocessor library myself. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ralf W. Grosse-Kunstleve</dc:creator> <pubDate>Wed, 01 Oct 2008 15:27:33 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2069#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2069#comment:13</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/2069#comment:12" title="Comment 12">danieljames</a>: </p> <blockquote class="citation"> <p> Sorry, I've been very slack. Here are the patches I've submitted: <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2375" title="#2375: Bugs: Fix gcc 4.4 preprocessor problem in Function Types (closed: invalid)">#2375</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2376" title="#2376: Patches: Fix gcc 4.4 preprocessor problem in Fusion (closed: invalid)">#2376</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2377" title="#2377: Bugs: Fix gcc 4.4 preprocessor problem in Proto. (closed: fixed)">#2377</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2378" title="#2378: Patches: Fix gcc 4.4 preprocessor problem in Phoenix (closed: invalid)">#2378</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2379" title="#2379: Patches: Fix gcc 4.4 preprocessor problem in Variant (closed: invalid)">#2379</a>. </p> </blockquote> <p> Are you planning to check these patches in yourself? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Daniel James</dc:creator> <pubDate>Tue, 07 Oct 2008 00:15:11 GMT</pubDate> <title>status, component changed; resolution set https://svn.boost.org/trac10/ticket/2069#comment:14 https://svn.boost.org/trac10/ticket/2069#comment:14 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> <li><strong>component</strong> <span class="trac-field-old">preprocessor</span> → <span class="trac-field-new">mpl</span> </li> </ul> <p> I've finally got round to fully testing the patches and I discovered that the problem only effects the mpl library. It uses a complicated system to preprocess the header files in advance for compilers which have slow preprocessors, and this was preventing it from including the preprocessor library. In all the other libraries <code>&lt;boost/preprocessor/iteration/iterator.hpp&gt;</code> is included by the time the <code>#elif</code> is reached so the problem doesn't occur. </p> <p> So, this really was an mpl bug and not a preprocessor bug. If you want to, you can problably revert the changes to python. I'm going to try to get python testing working so I can see if it works without the patch but that might take me a little while. Sorry for the hassle. I'm closing the ticket as your patch fixed the problem in mpl. </p> Ticket Daniel James Fri, 10 Oct 2008 19:58:48 GMT <link>https://svn.boost.org/trac10/ticket/2069#comment:15 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2069#comment:15</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/49257" title="Merge the mpl fixes for gcc 4.4. (But not the python ones). Refs ...">[49257]</a>) Merge the mpl fixes for gcc 4.4. (But not the python ones). Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2069" title="#2069: Bugs: #elif behaviour in gcc 4.4 (closed: fixed)">#2069</a>. </p> <p> Merged revisions 48960 via svnmerge from <a class="ext-link" href="https://svn.boost.org/svn/boost/trunk"><span class="icon">​</span>https://svn.boost.org/svn/boost/trunk</a> </p> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/48960" title="boost/python, boost/mpl: gcc 4.4 compatibility (see ...">r48960</a> | rwgk | 2008-09-25 05:49:24 +0100 (Thu, 25 Sep 2008) | 1 line </p> </blockquote> <p> </p> <blockquote> <p> boost/python, boost/mpl: gcc 4.4 compatibility (see <a class="ext-link" href="http://svn.boost.org/trac/boost/ticket/2069"><span class="icon">​</span>http://svn.boost.org/trac/boost/ticket/2069</a>) </p> </blockquote> <p> ........ </p> </description> <category>Ticket</category> </item> <item> <dc:creator>albermg7</dc:creator> <pubDate>Fri, 15 Nov 2013 12:05:31 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2069#comment:16 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2069#comment:16</guid> <description> <p> Thanks a lot for your changes <a class="missing wiki">DanielJames</a>. 5 years ago and I am gonna use your files to fix my boost version required to build Flexsus :D </p> </description> <category>Ticket</category> </item> </channel> </rss>