]> granicus.if.org Git - icu/commitdiff
ICU-20797 fix UBS compilation error and UBS in test code
authorSteven R. Loomis <srloomis@us.ibm.com>
Sat, 31 Aug 2019 00:31:38 +0000 (17:31 -0700)
committerSteven R. Loomis <srl295@gmail.com>
Tue, 17 Mar 2020 16:11:58 +0000 (09:11 -0700)
Two issues here:

- fix 2 build issue in i18n when compiling with clang++ -fsanitize=undefined
the following two symbols were not exported (and they should be):
  typeinfo for icu::CollationCacheEntry
  typeinfo for icu::numparse::impl::CodePointMatcher

- remove undefined behavior warning in NumberFormatTestTuple.. minor, but very annoying
when repeated many times during every test run. Tends to mask real errors.

> numberformattesttuple.cpp:319:5: runtime error: member access within null pointer of type 'NumberFormatTestTuple'

icu4c/source/i18n/collationtailoring.h
icu4c/source/i18n/numparse_affixes.h
icu4c/source/test/intltest/numberformattesttuple.cpp

index 9a636cf1eb9aa3ca27dbbe62b2be21c739035066..e1bc34c7d7683b8198b8e37dd09a971e6b2d5c7d 100644 (file)
@@ -92,7 +92,7 @@ private:
     CollationTailoring(const CollationTailoring &other);
 };
 
-struct CollationCacheEntry : public SharedObject {
+struct U_I18N_API CollationCacheEntry : public SharedObject {
     CollationCacheEntry(const Locale &loc, const CollationTailoring *t)
             : validLocale(loc), tailoring(t) {
         if(t != NULL) {
index e02b17ba2d0852052d0d4fbe6fe9639cc5aab4e1..97a17f4d78caecb57780a7125b5cfdd0caac1e17 100644 (file)
@@ -28,7 +28,7 @@ using ::icu::number::impl::TokenConsumer;
 using ::icu::number::impl::CurrencySymbols;
 
 
-class CodePointMatcher : public NumberParseMatcher, public UMemory {
+class U_I18N_API CodePointMatcher : public NumberParseMatcher, public UMemory {
   public:
     CodePointMatcher() = default;  // WARNING: Leaves the object in an unusable state
 
index 26db1ad11633b1c3f186f7c334231fd0720c3ae3..b73e67ef68f5b8a8e26e13fcf72dd43f754bae81 100644 (file)
@@ -16,7 +16,9 @@
 #include "cstring.h"
 #include "cmemory.h"
 
-static NumberFormatTestTuple *gNullPtr = NULL;
+static NumberFormatTestTuple emptyObject;
+
+static NumberFormatTestTuple *gNullPtr = &emptyObject;
 
 #define FIELD_OFFSET(fieldName) ((int32_t) (((char *) &gNullPtr->fieldName) - ((char *) gNullPtr)))
 #define FIELD_FLAG_OFFSET(fieldName) ((int32_t) (((char *) &gNullPtr->fieldName##Flag) - ((char *) gNullPtr)))