Address `-Wclass-memaccess' warnings from GCC 10.x.

Change-Id: Iaf84b498f8a63bf862126a12f3db7638ebd12f30
Reviewed-on: https://code-review.googlesource.com/c/re2/+/57798
Reviewed-by: Paul Wankadia <junyer@google.com>
diff --git a/re2/testing/tester.cc b/re2/testing/tester.cc
index 67d262c..d2ec4fb 100644
--- a/re2/testing/tester.cc
+++ b/re2/testing/tester.cc
@@ -86,6 +86,20 @@
 
 // The result of running a match.
 struct TestInstance::Result {
+  Result()
+      : skipped(false),
+        matched(false),
+        untrusted(false),
+        have_submatch(false),
+        have_submatch0(false) {
+    ClearSubmatch();
+  }
+
+  void ClearSubmatch() {
+    for (int i = 0; i < kMaxSubmatch; i++)
+      submatch[i] = StringPiece();
+  }
+
   bool skipped;         // test skipped: wasn't applicable
   bool matched;         // found a match
   bool untrusted;       // don't really trust the answer
@@ -292,9 +306,6 @@
                              const StringPiece& orig_context,
                              Prog::Anchor anchor,
                              Result* result) {
-  // Result is not trivial, so we cannot freely clear it with memset(3),
-  // but zeroing objects like so is safe and expedient for our purposes.
-  memset(reinterpret_cast<void*>(result), 0, sizeof *result);
   if (regexp_ == NULL) {
     result->skipped = true;
     return;
@@ -478,7 +489,7 @@
   }
 
   if (!result->matched)
-    memset(result->submatch, 0, sizeof result->submatch);
+    result->ClearSubmatch();
 }
 
 // Checks whether r is okay given that correct is the right answer.