[Regex] problems compiling with gcc 4.4

Hi, I am using boost 1.37 on osx from macports and I have a problem using the regex library with gcc 4.4, although it seems to work perfectly with gcc 4.3 and 4.2. The problem is with creating a boost::regex object- simple program below: #include <boost/regex.hpp> #include <string> int main(int argc, char **argv) { std::string s("(.*)bar|(.*)bah"); boost::regex re_node(s); return 1; } The backtrace it produces is below: (gdb) bt #0 0x90d90b9e in __kill () #1 0x90d90b91 in kill$UNIX2003 () #2 0x90e07ec2 in raise () #3 0x90e1747f in abort () #4 0x0026792c in __gnu_cxx::__verbose_terminate_handler () #5 0x00265239 in __cxxabiv1::__terminate () #6 0x0026527d in std::terminate () #7 0x0026539c in __cxa_throw () #8 0x001eeb00 in std::__throw_bad_cast () #9 0x00370d25 in std::use_facet<std::messages<char> > () #10 0x00127c93 in boost::re_detail::cpp_regex_traits_base<char>::imbue () at cpp_regex_traits.hpp:215 #11 regex_data [inlined] () at basic_regex.hpp:173 #12 basic_regex_implementation (this=0x500200) at cpp_regex_traits.hpp:93 #13 0x001256a6 in shared_ptr<boost::re_detail::basic_regex_implementation<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > > [inlined] () at shared_ptr.hpp:525 #14 boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign (this=0xbfffe790, p1=0x5001ec "(.*)bar|(.*)bah", p2=0x5001fb "", f=0) at basic_regex.hpp:525 #15 0x00001d6a in boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign () #16 0x00001d3e in boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign<std::char_traits<char>, std::allocator<char> > () #17 0x00001c9f in boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::basic_regex<std::char_traits<char>, std::allocator<char> > () #18 0x00001b20 in main () (gdb) Is this a problem with boost, or with the compiler? Any ideas for a fix? many thanks, a

Aonghus Lawlor a écrit :
The backtrace it produces is below:
What is the compile command line ? What message is displayed (without the debugger) ? -- Mickaël Wolff aka Lupus Michaelis Racine <http://lupusmic.org> Blog <http://blog.lupusmic.org>

Aonghus Lawlor wrote:
Hi,
I am using boost 1.37 on osx from macports and I have a problem using the regex library with gcc 4.4, although it seems to work perfectly with gcc 4.3 and 4.2.
The problem is with creating a boost::regex object- simple program below:
Looking at the backtrace the std::messages facet seems to be failing, can you try something like: std::locale l; std::use_facet<std::messages<char> >(l); and see if that also crashes? Thanks, John.

On Sun, Dec 14, 2008 at 9:37 AM, John Maddock <john@johnmaddock.co.uk>wrote:
Aonghus Lawlor wrote:
Hi,
I am using boost 1.37 on osx from macports and I have a problem using the regex library with gcc 4.4, although it seems to work perfectly with gcc 4.3 and 4.2.
The problem is with creating a boost::regex object- simple program below:
Looking at the backtrace the std::messages facet seems to be failing, can you try something like:
std::locale l; std::use_facet<std::messages<char> >(l);
and see if that also crashes?
Thanks, John.
Thanks for the suggestion- I tried this line: const std::locale locale; const std::messages<char>& msgs = std::use_facet< std::messages<char> >( locale ); but it makes no difference- the program still crashes only with gcc-4.4, and not previous versions. This is the compile command I am using (on osx): g++-mp-4.4 -g -o boost_test_regex boost_test_regex.C -I/opt/local/include/boost -L/opt/local/lib -lboost_regex-mt and it terminates like this: $ ./boost_test_regex terminate called after throwing an instance of 'std::bad_cast' what(): std::bad_cast Abort trap The gcc-4.4 is from macports, and was working fine with the rest of my code, until I ran into this problem with boost: $ g++-mp-4.4 -v Using built-in specs. Target: i386-apple-darwin9.5.0 Configured with: ../gcc-4.4-20081128/configure --prefix=/opt/local --enable-languages=c,c++,objc,obj-c++ --libdir=/opt/local/lib/gcc44 --includedir=/opt/local/include/gcc44 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.4 --with-gxx-include-dir=/opt/local/include/gcc44/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local Thread model: posix gcc version 4.4.0 20081128 (experimental) (GCC) I'm not really familiar with the usage of locale's and use_facet's , so I'm grateful for any other suggestions you might have, thanks, a

Aonghus Lawlor wrote:
Thanks for the suggestion- I tried this line:
const std::locale locale; const std::messages<char>& msgs = std::use_facet< std::messages<char> >( locale );
but it makes no difference- the program still crashes only with gcc-4.4, and not previous versions.
I don't follow: does the above code run OK, but regex still crashes?
This is the compile command I am using (on osx):
g++-mp-4.4 -g -o boost_test_regex boost_test_regex.C -I/opt/local/include/boost -L/opt/local/lib -lboost_regex-mt
and it terminates like this:
$ ./boost_test_regex terminate called after throwing an instance of 'std::bad_cast' what(): std::bad_cast Abort trap
The gcc-4.4 is from macports, and was working fine with the rest of my code, until I ran into this problem with boost:
$ g++-mp-4.4 -v Using built-in specs. Target: i386-apple-darwin9.5.0 Configured with: ../gcc-4.4-20081128/configure --prefix=/opt/local --enable-languages=c,c++,objc,obj-c++ --libdir=/opt/local/lib/gcc44 --includedir=/opt/local/include/gcc44 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.4 --with-gxx-include-dir=/opt/local/include/gcc44/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local Thread model: posix gcc version 4.4.0 20081128 (experimental) (GCC)
I'm not really familiar with the usage of locale's and use_facet's , so I'm grateful for any other suggestions you might have,
None at present, other than use a released version of gcc rather than the current 4.4 development branch. Probably your best bet is to report this as a bug to the gcc folks - if you need help in figuring out a test case let me know - but as I don't have access to that platform you'll have to do most of the work! Cheers, John.

On Sun, Dec 14, 2008 at 6:13 PM, John Maddock <john@johnmaddock.co.uk>wrote:
Aonghus Lawlor wrote:
Thanks for the suggestion- I tried this line:
const std::locale locale; const std::messages<char>& msgs = std::use_facet< std::messages<char> >( locale );
but it makes no difference- the program still crashes only with gcc-4.4, and not previous versions.
I don't follow: does the above code run OK, but regex still crashes?
no, it doesnt run- it crashes with the same backtrace as before: (gdb) bt #0 0x90d90b9e in __kill () #1 0x90d90b91 in kill$UNIX2003 () #2 0x90e07ec2 in raise () #3 0x90e1747f in abort () #4 0x0026792c in __gnu_cxx::__verbose_terminate_handler () #5 0x00265239 in __cxxabiv1::__terminate () #6 0x0026527d in std::terminate () #7 0x0026539c in __cxa_throw () #8 0x001eeb00 in std::__throw_bad_cast () #9 0x00370d25 in std::use_facet<std::messages<char> > () #10 0x00127c93 in boost::re_detail::basic_regex_implementation<char, boost::regex_traits<char, boost::cpp_regex_traits<char> >
::basic_regex_implementation () #11 0x001256a6 in boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign () #12 0x00001d6a in boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign () #13 0x00001d3e in boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign<std::char_traits<char>, std::allocator<char> > () #14 0x00001c9f in boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::basic_regex<std::char_traits<char>, std::allocator<char> > () #15 0x00001b05 in main ()
This is the compile command I am using (on osx):
g++-mp-4.4 -g -o boost_test_regex boost_test_regex.C -I/opt/local/include/boost -L/opt/local/lib -lboost_regex-mt
and it terminates like this:
$ ./boost_test_regex terminate called after throwing an instance of 'std::bad_cast' what(): std::bad_cast Abort trap
The gcc-4.4 is from macports, and was working fine with the rest of my code, until I ran into this problem with boost:
$ g++-mp-4.4 -v Using built-in specs. Target: i386-apple-darwin9.5.0 Configured with: ../gcc-4.4-20081128/configure --prefix=/opt/local --enable-languages=c,c++,objc,obj-c++ --libdir=/opt/local/lib/gcc44 --includedir=/opt/local/include/gcc44 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.4 --with-gxx-include-dir=/opt/local/include/gcc44/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local Thread model: posix gcc version 4.4.0 20081128 (experimental) (GCC)
I'm not really familiar with the usage of locale's and use_facet's , so I'm grateful for any other suggestions you might have,
None at present, other than use a released version of gcc rather than the current 4.4 development branch. Probably your best bet is to report this as a bug to the gcc folks - if you need help in figuring out a test case let me know - but as I don't have access to that platform you'll have to do most of the work!
fair enough- I figured it might have been a bug in boost- but I'll report it to the gcc list anyway, thanks, a
Cheers, John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Aonghus Lawlor
-
John Maddock
-
Mickael Wolff