random_test, GCC and minmax macros

The 'random_test' has been failing on GCC-3.3 for quite some time... Looking a bit deeper the failure was rather nasty resulting in a infinite recursion. A lot of waist CPU and memory usage when running regression tests! The problem is GCC-3.3 specific and cause by a compiler bug. It was inadvertently introduced by Eric minmax workarounds. Specificly the 'max' member functions of class ruetti_gen in "random_test.cpp" and class rand48 in "linear_congruential.hpp" were defined: result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return (std::numeric_limits<result_type>::max)(); } Amazingly these are recursing, with max calling itseld rather then the correct max from numeric_limits! I have committed a fix which uses a different syntax thus: result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return std::numeric_limits<result_type>::max BOOST_PREVENT_MACRO_SUBSTITUTION (); } Eric, is this correct from a minmax macro point of view? -- ___________________________________ Michael Stevens Systems Engineering Navigation Systems, Estimation and Bayesian Filtering http://bayesclasses.sf.net ___________________________________

Michael Stevens wrote:
The 'random_test' has been failing on GCC-3.3 for quite some time...
Looking a bit deeper the failure was rather nasty resulting in a infinite recursion. A lot of waist CPU and memory usage when running regression tests!
The problem is GCC-3.3 specific and cause by a compiler bug. It was inadvertently introduced by Eric minmax workarounds.
Specificly the 'max' member functions of class ruetti_gen in "random_test.cpp" and class rand48 in "linear_congruential.hpp" were defined:
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return (std::numeric_limits<result_type>::max)(); }
Amazingly these are recursing, with max calling itseld rather then the correct max from numeric_limits! I have committed a fix which uses a different syntax thus:
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return std::numeric_limits<result_type>::max BOOST_PREVENT_MACRO_SUBSTITUTION (); }
Eric, is this correct from a minmax macro point of view?
Yes, this is fine. But I'm amazed the compiler got it wrong the first time. (/me scratches his head and looks perplexed.) -- Eric Niebler Boost Consulting www.boost-consulting.com
participants (2)
-
Eric Niebler
-
Michael Stevens