Subject: Re: [Boost-bugs] [Boost C++ Libraries] #6126: Signed integer members of Boost.Fusion adapted ADTs are not output correctly with Boost.Spirit.Karma rules
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-01-31 14:36:53
#6126: Signed integer members of Boost.Fusion adapted ADTs are not output
correctly with Boost.Spirit.Karma rules
-------------------------------+--------------------------------------------
Reporter: t0rt1e@⦠| Owner: hkaiser
Type: Bugs | Status: new
Milestone: To Be Determined | Component: spirit
Version: Boost 1.48.0 | Severity: Regression
Resolution: | Keywords: patch proposed, Boost.Spirit.Karma, Boost.Fusion, BOOST_FUSION_ADAPT_CLASS, BOOST_FUSION_ADAPT_ADT, short, int, long
-------------------------------+--------------------------------------------
Comment (by t0rt1e@â¦):
I tried to dig further into the problem by following Seth Heren's debug
into the {{{any_integer_iterator::insert_int()}}} member function at
{{{boost/spirit/home/karma/numeric/int.hpp:210}}} when executing the
compiled {{{test_short_output_with_karma.cpp}}}. I could further narrow
down the moment, when the {{{*attr}}} value becomes zero by serializing
the statements and inlining the {{{sign_inserter::call}}} (see attached
diagnostic patch
{{{boost_spirit_home_karma_numeric_int_diagnostic.patch}}} against Boost
trunk 76795). The {{{*attr}}} value becomes zero after a character is put
into the {{{sink}}}, which happens in our case in line
{{{boost/spirit/home/karma/numeric/int.hpp:221}}}. Why??? Has anyone an
idea? Before everything is OK. I tested it by copying the Attribute via a
dummy function into another variable. Here's the relevant code snippet
with some comments:
{{{
template <typename OutputIterator, typename Attribute>
static bool insert_int(OutputIterator& sink, Attribute const&
attr)
{
// I have serialized the calls to better follow with the
debugger what's going on.
bool is_zero = traits::test_zero(attr);
bool is_neg = traits::test_negative(attr);
// Until here everything seems OK, *attr still has its value.
// I can use, e.g., the attribute in a function call.
Attribute attr_copy = dummy_function(attr);
// bool r1 = sign_inserter::call(sink, is_zero
// , is_neg, force_sign);
// After the sign_inserter call, *attr becomes surprisingly
zero.
// Therefore, I inlined the important code parts to output the
sign.
if (is_neg) {
*sink = '-';
// After putting the character into the sink, the *attr
becomes zero.
// Why??? This happens consistently unimportant whether it's
// compiled using g++ or clang++ on Linux or Mac OS X. Is the
sink
// not correctly constructed and leaks memory?
++sink;
} else if (force_sign) {
if (is_zero) {
*sink = ' ';
} else {
*sink = '+';
}
++sink;
}
bool r1 = true;
bool r2 = int_inserter<Radix, CharEncoding, Tag>::call(sink
, traits::get_absolute_value(attr));
return r1 && r2;
// return sign_inserter::call(sink, traits::test_zero(attr)
// , traits::test_negative(attr), force_sign) &&
// int_inserter<Radix, CharEncoding, Tag>::call(sink
// , traits::get_absolute_value(attr));
}
// Dummy function for pure diagnostic reasons. It just returns a
copy of the attribute.
template<typename Attribute>
static Attribute dummy_function(Attribute const& attr) {
return attr;
};
}}}
I'm not anymore sure that we are facing a compiler bug. Maybe the
{{{sink}}} is for some reason not correctly initialized?
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/6126#comment:11> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:08 UTC