Index: boost/spirit/home/karma/numeric/int.hpp =================================================================== --- boost/spirit/home/karma/numeric/int.hpp (Revision 76398) +++ boost/spirit/home/karma/numeric/int.hpp (Arbeitskopie) @@ -207,10 +207,25 @@ template static bool insert_int(OutputIterator& sink, Attribute const& attr) { - return sign_inserter::call(sink, traits::test_zero(attr) - , traits::test_negative(attr), force_sign) && + // For unknown reasons, the attr value is not passed + // correctly to traits::get_absolute_value() if it is not + // previously copied into a temporary variable. Seth + // Heeren et Jeroen Habraken + // from the Boost.Spirit general + // mailing list suspect a compiler error (which would be + // surprisingly present in g++ and clang++, but is not + // observed in MSVC) or a subtle case of undefined + // behavior in C++. + Attribute attr_copy(attr); + return sign_inserter::call(sink, traits::test_zero(attr_copy) + , traits::test_negative(attr_copy), force_sign) && int_inserter::call(sink - , traits::get_absolute_value(attr)); + , traits::get_absolute_value(attr_copy)); + // // The original code without the workaround: + // return sign_inserter::call(sink, traits::test_zero(attr) + // , traits::test_negative(attr), force_sign) && + // int_inserter::call(sink + // , traits::get_absolute_value(attr)); } public: