Bug 8195 – Segfault when comparing a VariantN to a non-variant type which it holds
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-06-03T21:54:00Z
Last change time
2015-06-09T05:15:03Z
Assigned to
nobody
Creator
issues.dlang
Comments
Comment #0 by issues.dlang — 2012-06-03T21:54:52Z
This code:
import std.typetuple;
import std.variant;
struct S
{
int a;
long b;
string c;
real d;
bool e;
}
private alias TypeTuple!(string,
int,
S) Types;
alias VariantN!(maxSize!Types, Types) MyVariant;
void main()
{
auto v = MyVariant(S.init);
assert(v == S.init);
}
segfaults when it's run. If you change the assertion to
assert(v == MyVariant(S.init));
then it runs just fine. This appears to only happen when a struct whose size is >= Variant.sizeof is in the list of accepted types.