diff --git a/src/strings.cpp b/src/strings.cpp index 826a8bd4f6..7fa1bad9c1 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -1098,8 +1098,12 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara case SCC_PLURAL_LIST: { // {P} int plural_form = *str++; // contains the plural form for this string size_t offset = orig_offset + (uint8_t)*str++; - int64_t v = std::get(args.GetParam(offset)); // contains the number that determines plural - str = ParseStringChoice(str, DeterminePluralForm(v, plural_form), builder); + const uint64_t *v = std::get_if(&args.GetParam(offset)); // contains the number that determines plural + if (v != nullptr) { + str = ParseStringChoice(str, DeterminePluralForm(static_cast(*v), plural_form), builder); + } else { + builder += "(invalid PLURAL parameter)"; + } break; }