Opened 14 years ago

Closed 14 years ago

#2535 closed Bugs (wontfix)

Boost.Regex not compatible with gcc's align-double at optimization level 3

Reported by: Andrew Troschinetz Owned by: John Maddock
Milestone: Boost 1.38.0 Component: regex
Version: Boost 1.37.0 Severity: Problem
Keywords: Cc: krivenok@…

Description

When compiling even the following code:

#include <boost/regex.h> int main { boost::regex ("test"); return 0; }

With the flags

-m32 -malign-double -O3

on gcc, a segfault occurs. Here is a sample excerpt of what gdb shows:

0x08066beb in boost::re_detail::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::parse_extended (this=0xffde311c)

at /usr/include/boost/regex/v4/basic_regex_parser.hpp:235

235 switch(this->m_traits.syntax_type(*m_position)) (gdb) print m_position $1 = 0x0 (gdb) bt #0 0x08066beb in boost::re_detail::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::parse_extended

at /usr/include/boost/regex/v4/basic_regex_parser.hpp:235

#1 0xf7f9e364 in boost ::re_detail::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::parse ()

from /usr/lib/libboost_regex.so.2

#2 0xf7fa0eba in boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign () from /usr/lib/libboost_regex.so.2

Change History (1)

comment:1 by John Maddock, 14 years ago

Resolution: wontfix
Status: newclosed

I believe that this is inevitable and not fixable (unless you can suggest otherwise), gcc's docs say:

"-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."

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.

HTH, and sorry for the bad news, John

Note: See TracTickets for help on using tickets.