ICU-21579 Fix warnings in number formatting code
diff --git a/icu4c/source/i18n/formattedvalue.cpp b/icu4c/source/i18n/formattedvalue.cpp
index 05a40ae..1030661 100644
--- a/icu4c/source/i18n/formattedvalue.cpp
+++ b/icu4c/source/i18n/formattedvalue.cpp
@@ -209,6 +209,8 @@
if (pLength != nullptr) {
*pLength = readOnlyAlias.length();
}
+ // Note: this line triggers -Wreturn-local-addr, but it is safe because toTempString is
+ // defined to return memory owned by the ufmtval argument.
return readOnlyAlias.getBuffer();
}
diff --git a/icu4c/source/i18n/number_skeletons.cpp b/icu4c/source/i18n/number_skeletons.cpp
index ba9eee6..de70c5c 100644
--- a/icu4c/source/i18n/number_skeletons.cpp
+++ b/icu4c/source/i18n/number_skeletons.cpp
@@ -1358,7 +1358,9 @@
priority = UNUM_ROUNDING_PRIORITY_STRICT;
offset++;
} else {
- U_ASSERT(offset < segment.length());
+ // Invalid digits option for fraction rounder
+ status = U_NUMBER_SKELETON_SYNTAX_ERROR;
+ return false;
}
if (offset < segment.length()) {
// Invalid digits option for fraction rounder