Rework a few character arrays.
In order to avoid narrowing conversion errors, cast each value to char
explicitly. Note that the UTF-8 test already did it like this.
Fixes #21.
Change-Id: I88321547365dcafb806c70880522943fa0c88272
Reviewed-on: https://code-review.googlesource.com/2361
Reviewed-by: Paul Wankadia <junyer@google.com>
diff --git a/re2/testing/re2_test.cc b/re2/testing/re2_test.cc
index d80f313..efd3a20 100644
--- a/re2/testing/re2_test.cc
+++ b/re2/testing/re2_test.cc
@@ -1432,10 +1432,14 @@
TEST(RE2, Bug18391750) {
// Stray write past end of match_ in nfa.cc, caught by fuzzing + address sanitizer.
- char t[] = {0x28, 0x28, 0xfc, 0xfc, 0x8, 0x8, 0x26, 0x26, 0x28, 0xc2, 0x9b,
- 0xc5, 0xc5, 0xd4, 0x8f, 0x8f, 0x69, 0x69, 0xe7, 0x29, 0x7b, 0x37,
- 0x31, 0x31, 0x7d, 0xae, 0x7c, 0x7c, 0xf3, 0x29, 0xae, 0xae, 0x2e,
- 0x2a, 0x29, 0x0};
+ const char t[] = {
+ (char)0x28, (char)0x28, (char)0xfc, (char)0xfc, (char)0x08, (char)0x08,
+ (char)0x26, (char)0x26, (char)0x28, (char)0xc2, (char)0x9b, (char)0xc5,
+ (char)0xc5, (char)0xd4, (char)0x8f, (char)0x8f, (char)0x69, (char)0x69,
+ (char)0xe7, (char)0x29, (char)0x7b, (char)0x37, (char)0x31, (char)0x31,
+ (char)0x7d, (char)0xae, (char)0x7c, (char)0x7c, (char)0xf3, (char)0x29,
+ (char)0xae, (char)0xae, (char)0x2e, (char)0x2a, (char)0x29, (char)0x00,
+ };
RE2::Options opt;
opt.set_encoding(RE2::Options::EncodingLatin1);
opt.set_longest_match(true);
@@ -1450,8 +1454,11 @@
// Bug in parser accepting invalid (too large) rune,
// causing compiler to fail in DCHECK in UTF-8
// character class code.
- char b[] = {0x28, 0x5, 0x5, 0x41, 0x41, 0x28, 0x24, 0x5b, 0x5e,
- 0xf5, 0x87, 0x87, 0x90, 0x29, 0x5d, 0x29, 0x29, 0x0};
+ const char b[] = {
+ (char)0x28, (char)0x05, (char)0x05, (char)0x41, (char)0x41, (char)0x28,
+ (char)0x24, (char)0x5b, (char)0x5e, (char)0xf5, (char)0x87, (char)0x87,
+ (char)0x90, (char)0x29, (char)0x5d, (char)0x29, (char)0x29, (char)0x00,
+ };
RE2 re(b);
CHECK(!re.ok());
}
@@ -1460,8 +1467,12 @@
// Bug in bitstate: case kFailInst was merged into the default with LOG(DFATAL).
RE2::Options opt;
- char a[] = {0x29, 0x29, 0x24, 0x0};
- char b[] = {0x28, 0xa, 0x2a, 0x2a, 0x29, 0x0};
+ const char a[] = {
+ (char)0x29, (char)0x29, (char)0x24, (char)0x00,
+ };
+ const char b[] = {
+ (char)0x28, (char)0x0a, (char)0x2a, (char)0x2a, (char)0x29, (char)0x00,
+ };
opt.set_log_errors(false);
opt.set_encoding(RE2::Options::EncodingLatin1);
opt.set_posix_syntax(true);