Boost logo

Boost Users :

Subject: [Boost-users] [variant] 'which' out of range assertion
From: Igor R (boost.lists_at_[hidden])
Date: 2012-02-22 10:25:39


Hello,

It appears that since 1.47 Boost.Variant has a bug that can be
reproduced as follows (MSVC10, Debug mode):

#include <boost/variant.hpp>
#include <boost/mpl/vector/vector30.hpp>

struct struct1{};
struct struct2{};
struct struct3{};
struct struct4{};
struct struct5{};
struct struct6{};
struct struct7{};
struct struct8{};
struct struct9{};
struct struct10{};
struct struct11{};
struct struct12{};
struct struct13{};
struct struct14{};
struct struct15{};
struct struct16{};
struct struct17{};
struct struct18{};
struct struct19{};
struct struct20{};
struct struct21{};

typedef boost::mpl::vector21<
struct1,
struct2,
struct3,
struct4,
struct5,
struct6,
struct7,
struct8,
struct9,
struct10,
struct11,
struct12,
struct13,
struct14,
struct15,
struct16,
struct17,
struct18,
struct19,
struct20,
struct21
>::type vec_type;
typedef boost::make_variant_over<vec_type>::type var_type;

int main()
{
  var_type v;
  v = struct21();
}

The last line generates assertion in variant_impl.hpp, line 264,
visitation_impl() function: "Boost.Variant internal error: 'which' out
of range."

According to the release notes, variant wasn't changed in 1.47, but I
recalled teh following discussion:
http://boost.2283326.n4.nabble.com/large-variant-performance-compared-50-elements-tt3204484.html#a3205490
It seems that the above issue is somehow related to this change.

Igor'.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net