Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MSVC runtime check failure #5557

Merged
merged 2 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* None.

### Fixed
* <How do the end-user experience this issue? what was the impact?> ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?)
* None.
* Fixed a segfault in sync compiled by MSVC 2022. ([#5557](https://github.com/realm/realm-core/pull/5557), since 12.1.0)

### Breaking changes
* None.
Expand Down
25 changes: 13 additions & 12 deletions src/realm/sync/changeset_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ void ChangesetEncoder::operator()(const Instruction::AddTable& instr)
{
auto spec = mpark::get_if<Instruction::AddTable::TopLevelTable>(&instr.type);
const bool is_embedded = (spec == nullptr);
auto convert = util::overload{
[&](const Instruction::AddTable::TopLevelTable& spec) {
if (spec.is_asymmetric) {
return Table::Type::TopLevelAsymmetric;
}
return Table::Type::TopLevel;
},
[&](const Instruction::AddTable::EmbeddedTable&) {
return Table::Type::Embedded;
},
};
auto table_type_int = static_cast<uint8_t>(mpark::visit(convert, instr.type));
Table::Type table_type;
if (!is_embedded) {
if (spec->is_asymmetric) {
table_type = Table::Type::TopLevelAsymmetric;
}
else {
table_type = Table::Type::TopLevel;
}
}
else {
table_type = Table::Type::Embedded;
}
auto table_type_int = static_cast<uint8_t>(table_type);
append(Instruction::Type::AddTable, instr.table, table_type_int);
if (!is_embedded) {
append_value(spec->pk_field);
Expand Down