aboutsummaryrefslogtreecommitdiffstats
path: root/include/gmock/gmock-matchers.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/gmock/gmock-matchers.h')
-rw-r--r--include/gmock/gmock-matchers.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/include/gmock/gmock-matchers.h b/include/gmock/gmock-matchers.h
index 962cfde9..d4977273 100644
--- a/include/gmock/gmock-matchers.h
+++ b/include/gmock/gmock-matchers.h
@@ -1613,10 +1613,12 @@ class PredicateFormatterFromMatcher {
// know which type to instantiate it to until we actually see the
// type of x here.
//
- // We write MatcherCast<const T&>(matcher_) instead of
+ // We write SafeMatcherCast<const T&>(matcher_) instead of
// Matcher<const T&>(matcher_), as the latter won't compile when
// matcher_ has type Matcher<T> (e.g. An<int>()).
- const Matcher<const T&> matcher = MatcherCast<const T&>(matcher_);
+ // We don't write MatcherCast<const T&> either, as that allows
+ // potentially unsafe downcasting of the matcher argument.
+ const Matcher<const T&> matcher = SafeMatcherCast<const T&>(matcher_);
StringMatchResultListener listener;
if (MatchPrintAndExplain(x, matcher, &listener))
return AssertionSuccess();