Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-01-27 19:26:59


Using FreeBSD 3.4 and GCC 3.0.3, running any of the regex examples or tests
proves quite fatal. Here's a partial backtrace from one of the core dumps:

#0 0x80612fe in isalpha (c=0) at regex/config.hpp:347
#1 0x8061306 in isalpha (c=0) at regex/config.hpp:347
#2 0x8061306 in isalpha (c=0) at regex/config.hpp:347
#3 0x8061306 in isalpha (c=0) at regex/config.hpp:347
#4 0x8061306 in isalpha (c=0) at regex/config.hpp:347
#5 0x8061306 in isalpha (c=0) at regex/config.hpp:347
#6 0x8061306 in isalpha (c=0) at regex/config.hpp:347
#7 0x8061306 in isalpha (c=0) at regex/config.hpp:347
#8 0x8061306 in isalpha (c=0) at regex/config.hpp:347
#9 0x8061306 in isalpha (c=0) at regex/config.hpp:347
#10 0x8061306 in isalpha (c=0) at regex/config.hpp:347

It goes on for quite a while, but I won't bore you with that :)

The cause is this block in regex/config.hpp:

#ifdef BOOST_NO_CTYPE_FUNCTIONS

// Make functions out of the macros.
// Use parentheses so the macros don't screw us up.
inline int (isalpha)(int c) { return isalpha(c); }
inline int (iscntrl)(int c) { return iscntrl(c); }
inline int (isdigit)(int c) { return isdigit(c); }
inline int (islower)(int c) { return islower(c); }
inline int (ispunct)(int c) { return ispunct(c); }
inline int (isspace)(int c) { return isspace(c); }
inline int (isupper)(int c) { return isupper(c); }
inline int (isxdigit)(int c) { return isxdigit(c); }

#endif

The problem here is that even though FreeBSD's <ctype.h> defines all of the
above functions as macros (which config/platform/bsd.hpp knows about, and
thus consequently sets BOOST_NO_CTYPE_FUNCTIONS), GCC 3.x gets rid of these
macros and makes <cctype> better behaved. I suggest the following patch to
boost/config/suffix.hpp, which has been successfully tested on the
aforementioned platform.

        Doug

Index: suffix.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/config/suffix.hpp,v
retrieving revision 1.9
diff -c -3 -p -r1.9 suffix.hpp
*** suffix.hpp 2002/01/24 16:32:22 1.9
--- suffix.hpp 2002/01/27 23:10:37
***************
*** 33,38 ****
--- 33,45 ----
  # define BOOST_HAS_LONG_LONG
  #endif

+ // GCC 3.x will clean up all of those nasty macro definitions that
+ // BOOST_NO_CTYPE_FUNCTIONS is intended to help work around, so undefine
+ // it under GCC 3.x.
+ #if defined(__GNUC__) && (__GNUC__ >= 3) &&
defined(BOOST_NO_CTYPE_FUNCTIONS)
+ # undef BOOST_NO_CTYPE_FUNCTIONS
+ #endif
+
  //
  // Assume any extensions are in namespace std:: unless stated otherwise:
  //


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk