[clang] [Clang] prevented assertion failure by handling integral to boolean conversions for boolean vectors (PR #108657)

Oleksandr T. via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 17 03:59:14 PDT 2024


================
@@ -9868,7 +9868,12 @@ static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar,
   // if necessary.
   CastKind scalarCast = CK_NoOp;
 
-  if (vectorEltTy->isIntegralType(S.Context)) {
+  if (vectorEltTy->isBooleanType()) {
+    if (scalarTy->isIntegralType(S.Context))
+      scalarCast = CK_IntegralToBoolean;
+    else if (!scalarTy->isBooleanType())
----------------
a-tarasyuk wrote:

@shafik thanks for the feedback. I've removed uncovered cases. The _assertion failure_ occurs because `CK_IntegralCast` is used for an implicit cast from a `bool` vector...

https://github.com/llvm/llvm-project/blob/b6f72fc1e202c749333bd5b8ecb879d661af16b6/clang/lib/Sema/SemaExpr.cpp#L9880

https://github.com/llvm/llvm-project/blob/b6f72fc1e202c749333bd5b8ecb879d661af16b6/clang/lib/Sema/SemaExpr.cpp#L9901

I found a more specific kind, `CK_IntegralToBoolean`, which seems more relevant to this case. However, I couldn’t find any details about this in the spec, so I’d appreciate it if someone could clarify this specific case. Is this _kind_ not acceptable for this case?

https://github.com/llvm/llvm-project/pull/108657


More information about the cfe-commits mailing list