Skip to content

Commit

Permalink
Add workaround for std.algorithm.swap thinking that two Json objects …
Browse files Browse the repository at this point in the history
…overlap when they don't.
  • Loading branch information
s-ludwig committed Apr 25, 2013
1 parent adf1a11 commit b6afee0
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions source/vibe/data/json.d
Expand Up @@ -69,12 +69,29 @@ struct Json {
private {
union {
bool m_bool;
long m_int;
double m_float;
string m_string;
Json[] m_array;
Json[string] m_object;
};
}
// put each size into its own union to work around garbage that
// otherwise is in the unused area of the union. This garbage
// produces false GC references and causes std.algorithm.swap
// to choke because of pretended self-aliasing
static if ((void*).sizeof == 4) {
union {
long m_int;
double m_float;
Json[] m_array;
string m_string;
}
} else {
union {
long m_int;
double m_float;
}
union {
Json[] m_array;
string m_string;
}
}
Type m_type = Type.Undefined;
}

Expand Down

0 comments on commit b6afee0

Please sign in to comment.