Boost C++ Libraries: Ticket #910: gcc strict-aliasing problems with python https://svn.boost.org/trac10/ticket/910 <p> With the Boost 1.34.0 beta release candidate, and also with Boost 1.33.1, and probably before that too, building Boost.Python in release mode with a recent version of gcc (4.x) generates several occurrences of warnings: </p> <blockquote> <p> "dereferencing type-punned pointer will break strict aliasing rules" </p> </blockquote> <p> Beginning with Python 2.3 and at least through Python 2.5, when building Python with gcc, the gcc option -fno-strict-aliasing is used. So clearly the Python developers don't consider Python to be strict-aliasing correct (or else don't trust gcc's strict-aliasing analysis). </p> <p> The result of not being strict-aliasing correct when gcc's strict aliasing option is enabled (which I think is the default for gcc 4.0 onward, at least at high optimization levels) is that the compiler may generate non-working code. </p> <p> I don't have any specific evidence that the warnings from compiling Boost.Python indicate actual problems. These warnings may appear without there being any actual code generation differences. Unfortunately, that may vary from one version of gcc to another. Even worse, gcc may fail to generate warnings in cases where it does indeed generate non-working code. The best method I know of for finding instances of code broken by strict-aliasing based optimizations is to compile with and without that option, compare the generated code, and carefully examine the places that are different, with some differences being seemingly harmless. In other words, a very difficult and error-prone process. </p> <p> I recommend that building Boost.Python with recent versions of gcc similarly supply the -fno-strict-aliasing option, and that it should also be used when compiling code that uses Boost.Python. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/910 Trac 1.4.3 Dave Abrahams Tue, 03 Jul 2007 14:30:46 GMT owner, status, description changed; severity set https://svn.boost.org/trac10/ticket/910#comment:1 https://svn.boost.org/trac10/ticket/910#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">david_abrahams</span> to <span class="trac-author">Dave Abrahams</span> </li> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">new</span> </li> <li><strong>description</strong> modified (<a href="/trac10/ticket/910?action=diff&amp;version=1">diff</a>) </li> <li><strong>severity</strong> → <span class="trac-field-new">Showstopper</span> </li> </ul> Ticket Dave Abrahams Tue, 03 Jul 2007 14:36:48 GMT status, severity, version, description changed; milestone set https://svn.boost.org/trac10/ticket/910#comment:2 https://svn.boost.org/trac10/ticket/910#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Showstopper</span> → <span class="trac-field-new">Cosmetic</span> </li> <li><strong>version</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">release 1.34.0</span> </li> <li><strong>description</strong> modified (<a href="/trac10/ticket/910?action=diff&amp;version=2">diff</a>) </li> <li><strong>milestone</strong> → <span class="trac-field-new">Boost 1.35.0</span> </li> </ul> Ticket Dave Abrahams Fri, 27 Nov 2009 16:03:32 GMT <link>https://svn.boost.org/trac10/ticket/910#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/910#comment:3</guid> <description> <p> If we could find a way to do this everywhere except Py3K, it would be ideal. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Dave Abrahams</dc:creator> <pubDate>Fri, 27 Nov 2009 16:31:13 GMT</pubDate> <title>status, resolution changed https://svn.boost.org/trac10/ticket/910#comment:4 https://svn.boost.org/trac10/ticket/910#comment:4 <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-old">None</span> → <span class="trac-field-new">worksforme</span> </li> </ul> Ticket