Opened 7 years ago

Closed 6 years ago

#11751 closed Bugs (fixed)

variant of non-const references fails equality compare

Reported by: nikkoara@… Owned by: Antony Polukhin
Milestone: Boost 1.62.0 Component: variant
Version: Boost 1.59.0 Severity: Problem
Keywords: variant Cc:

Description

The following aborts:

#include <boost/variant.hpp>

using variant_type = boost::variant< int& >;

int main () {
    int a, b;

    variant_type v (a), u (b);
    v == u;

    return 0;
}

Compile and run:

$ g++ -std=c++14 -I/opt/boost/default/include t.cpp && ./a.out 
a.out: /opt/boost/default/include/boost/variant/detail/forced_return.hpp:39: T boost::detail::variant::forced_return() [with T = const int&]: Assertion `false' failed.
Aborted (core dumped)

It seems that the cause is the instantiation of known_get for const T at line 905 in variant.hpp (1.59.0).

Change History (4)

comment:1 by anonymous, 7 years ago

Component: Nonevariant
Owner: set to ebf

comment:2 by Antony Polukhin, 6 years ago

Milestone: To Be DeterminedBoost 1.62.0
Owner: changed from ebf to Antony Polukhin
Status: newassigned

comment:3 by Antony Polukhin, 6 years ago

Fixed in 082732aa develop, will be merged to master as soon as the tests will cycle.

comment:4 by Antony Polukhin, 6 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.