On 25/07/2014 08:33, Jacob Hart wrote:
> On Fri, Jul 25, 2014 at 4:00 PM, Sylvestre Ledru <[email protected]> wrote:
>> Hello,
>>
>> On 25/07/2014 06:06, hartja wrote:
>> Hi Sylvestre, Thanks for your reply. I have attached source code that
>> triggers the crash to this email. Fortunately the test case is quite
>> small -- I think the size blew out in the preprocessed version
>> because of the includes. Regards, Jacob.
OK. Thanks.
For the record, it was possible to reduce it a bit more (and probably
more again).
CF attachment.
Anyway, the bug is fixed in 3.5. I won't try to fix the patch to
backport the fix but if you want to try yourself
and the patch is minor, I could apply it to 3.4.
Cheers,
Sylvestre
#include <iostream>
#include <tuple>
namespace syntax {
typedef uint32_t error_t;
}
template <typename T> struct validator;
template <typename T> struct value_type;
namespace detail {
/** @require Validatable(T)
* @require Rule(R), Rule(Rs...) defined on T */
template <typename T, typename R, typename...Rs>
struct validator_base
{
typedef T type;
typedef std::tuple<R, Rs...> rule_set_t;
rule_set_t rule_set;
syntax::error_t operator()(const T& x) const
{
return evaluate_<std::tuple_size<rule_set_t>>(x);
}
protected:
~validator_base() = default;
template <unsigned N>
syntax::error_t evaluate_(const T& x)
{
validator<T>& v = static_cast<validator<T&>>(*this);
syntax::error_t error = rule_set<N>(v, x);
return error | evaluate_<N-1>(x)<<1;
}
};
template <typename T, typename R, typename...Rs>
syntax::error_t validator_base<T, R, Rs...>::evaluate_<0>(const T& x)
{
validator<T>& v = static_cast<validator<T&>>(*this);
return rule_set<0>(v, x);
};
} // detail