aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-04-18 12:05:54 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-04-18 12:05:54 +0000
commitb6eee077b23fa526e89570f01ec52c6ad335827b (patch)
tree68de33174d9b64052b7d4eebb2863e20d6ad7780 /lib
parent66821b5515df8a366579d023e472f843ecfa59b2 (diff)
Bail out early to avoid comparing the internals of two conversion sequences of
different kinds (aka garbage). This happens if we're comparing a standard conversion sequence to an ambiguous one which have the same KindRank. Found by valgrind. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101717 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Sema/SemaOverload.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 6772672bef..7a37daaa74 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -1763,6 +1763,11 @@ Sema::CompareImplicitConversionSequences(const ImplicitConversionSequence& ICS1,
else if (ICS2.getKindRank() < ICS1.getKindRank())
return ImplicitConversionSequence::Worse;
+ // The following checks require both conversion sequences to be of
+ // the same kind.
+ if (ICS1.getKind() != ICS2.getKind())
+ return ImplicitConversionSequence::Indistinguishable;
+
// Two implicit conversion sequences of the same form are
// indistinguishable conversion sequences unless one of the
// following rules apply: (C++ 13.3.3.2p3):