Skip to content

Commit d5ad28d

Browse files
committed
Always initialize fields in MatcherBase constructors
This fixes -Wuninitialized warnings with GCC. Fixes #3514.
1 parent 8ccdb9d commit d5ad28d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

googletest/include/gtest/gtest-matchers.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,17 +299,18 @@ class MatcherBase : private MatcherDescriberInterface {
299299
}
300300

301301
protected:
302-
MatcherBase() : vtable_(nullptr) {}
302+
MatcherBase() : vtable_(nullptr), buffer_() {}
303303

304304
// Constructs a matcher from its implementation.
305305
template <typename U>
306-
explicit MatcherBase(const MatcherInterface<U>* impl) {
306+
explicit MatcherBase(const MatcherInterface<U>* impl)
307+
: vtable_(nullptr), buffer_() {
307308
Init(impl);
308309
}
309310

310311
template <typename M, typename = typename std::remove_reference<
311312
M>::type::is_gtest_matcher>
312-
MatcherBase(M&& m) { // NOLINT
313+
MatcherBase(M&& m) : vtable_(nullptr), buffer_() { // NOLINT
313314
Init(std::forward<M>(m));
314315
}
315316

0 commit comments

Comments
 (0)