[clang] [clang][Sema] Fix assertion in `tryDiagnoseOverloadedCast` (PR #108021)
Alejandro Álvarez Ayllón via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 13 02:47:24 PDT 2024
================
@@ -446,7 +446,12 @@ static bool tryDiagnoseOverloadedCast(Sema &S, CastType CT,
: InitializationKind::CreateCast(/*type range?*/ range);
InitializationSequence sequence(S, entity, initKind, src);
- assert(sequence.Failed() && "initialization succeeded on second try?");
+ // It could happen that a constructor failed to be used because
+ // it requires a temporary of a broken type. Still, it will be found when
+ // looking for a match.
+ if (!sequence.Failed())
----------------
alejandro-alvarez-sonarsource wrote:
I have checked, and the destination type has no errors. I guess because the type itself is ok, the problem is that the constructor from `const char*` failed to be instantiated.
https://github.com/llvm/llvm-project/pull/108021
More information about the cfe-commits
mailing list