From b6eee077b23fa526e89570f01ec52c6ad335827b Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sun, 18 Apr 2010 12:05:54 +0000 Subject: [PATCH] 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 --- lib/Sema/SemaOverload.cpp | 5 +++++ 1 file changed, 5 insertions(+) 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): -- 2.40.0