Boost C++ Libraries: Ticket #2535: Boost.Regex not compatible with gcc's align-double at optimization level 3 https://svn.boost.org/trac10/ticket/2535 <p> When compiling even the following code: </p> <blockquote> <p> #include &lt;boost/regex.h&gt; int main { boost::regex ("test"); return 0; } </p> </blockquote> <p> With the flags </p> <blockquote> <p> -m32 -malign-double -O3 </p> </blockquote> <p> on gcc, a segfault occurs. Here is a sample excerpt of what gdb shows: </p> <p> 0x08066beb in boost::re_detail::basic_regex_parser&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::parse_extended (this=0xffde311c) </p> <blockquote> <p> at /usr/include/boost/regex/v4/basic_regex_parser.hpp:235 </p> </blockquote> <p> 235 switch(this-&gt;m_traits.syntax_type(*m_position)) (gdb) print m_position $1 = 0x0 (gdb) bt <a class="missing ticket">#0</a> 0x08066beb in boost::re_detail::basic_regex_parser&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::parse_extended </p> <blockquote> <p> at /usr/include/boost/regex/v4/basic_regex_parser.hpp:235 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1" title="#1: Bugs: boost.build causes ftjam to segfault (closed: Wont Fix)">#1</a> 0xf7f9e364 in boost ::re_detail::basic_regex_parser&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::parse () </p> <blockquote> <p> from /usr/lib/libboost_regex.so.2 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2" title="#2: Bugs: list::size should be const (closed: fixed)">#2</a> 0xf7fa0eba in boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::do_assign () from /usr/lib/libboost_regex.so.2 </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2535 Trac 1.4.3 John Maddock Wed, 26 Nov 2008 17:23:29 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2535#comment:1 https://svn.boost.org/trac10/ticket/2535#comment:1 <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">wontfix</span> </li> </ul> <p> I believe that this is inevitable and not fixable (unless you can suggest otherwise), gcc's docs say: </p> <p> "-malign-double -mno-align-double Control whether GCC aligns double, long double, and long long variables on a two word boundary or a one word boundary. Aligning double variables on a two word boundary will produce code that runs somewhat faster on a ‘Pentium’ at the expense of more memory. On x86-64, ‘-malign-double’ is enabled by default. Warning: if you use the ‘-malign-double’ switch, structures containing the above types will be aligned differently than the published application binary interface specifications for the 386 and will not be binary compatible with structures in code compiled without that switch." </p> <p> In other words setting that switch changes the binary compatibity of the code - so your application's obj files are no longer compatible with the way Boost.Regex is built by default. You would have to build regex with -malign-double if you insist on using that option. </p> <p> HTH, and sorry for the bad news, John </p> Ticket