Ticket #6126: karma_numeric_int_hpp.patch

File karma_numeric_int_hpp.patch, 1.8 KB (added by t0rt1e@…, 11 years ago)

Patch for boost/spirit/home/karma/numeric/int.hpp based on SVN rev. 76398

  • boost/spirit/home/karma/numeric/int.hpp

     
    207207        template <typename OutputIterator, typename Attribute>
    208208        static bool insert_int(OutputIterator& sink, Attribute const& attr)
    209209        {
    210             return sign_inserter::call(sink, traits::test_zero(attr)
    211                       , traits::test_negative(attr), force_sign) &&
     210            // For unknown reasons, the attr value is not passed
     211            // correctly to traits::get_absolute_value() if it is not
     212            // previously copied into a temporary variable. Seth
     213            // Heeren <bugs at sehe.nl> et Jeroen Habraken
     214            // <vexocide at gmail.com> from the Boost.Spirit general
     215            // mailing list suspect a compiler error (which would be
     216            // surprisingly present in g++ and clang++, but is not
     217            // observed in MSVC) or a subtle case of undefined
     218            // behavior in C++.
     219            Attribute attr_copy(attr);
     220            return sign_inserter::call(sink, traits::test_zero(attr_copy)
     221                      , traits::test_negative(attr_copy), force_sign) &&
    212222                   int_inserter<Radix, CharEncoding, Tag>::call(sink
    213                       , traits::get_absolute_value(attr));
     223                      , traits::get_absolute_value(attr_copy));
     224            // // The original code without the workaround:
     225            // return sign_inserter::call(sink, traits::test_zero(attr)
     226            //           , traits::test_negative(attr), force_sign) &&
     227            //        int_inserter<Radix, CharEncoding, Tag>::call(sink
     228            //           , traits::get_absolute_value(attr));
    214229        }
    215230
    216231    public: