================
@@ -17331,13 +17314,20 @@ ExprResult Sema::BuildVAArgExpr(SourceLocation 
BuiltinLoc,
       if (!PromoteType.isNull() && !UnderlyingType->isBooleanType() &&
           PromoteType->isUnsignedIntegerType() !=
               UnderlyingType->isUnsignedIntegerType()) {
-        UnderlyingType =
-            UnderlyingType->isUnsignedIntegerType()
-                ? Context.getCorrespondingSignedType(UnderlyingType)
-                : Context.getCorrespondingUnsignedType(UnderlyingType);
-        if (Context.typesAreCompatible(PromoteType, UnderlyingType,
-                                       /*CompareUnqualified*/ true))
-          PromoteType = QualType();
+
+        // Because char16_t and char32_t have no corresponding signed type,
+        // calling getCorrespondingSignedType on them would assert. Guard
+        // against this.
+        const auto *BT = UnderlyingType->getAs<BuiltinType>();
+        if (!BT || (BT->getKind() != BuiltinType::Char16 &&
+                    BT->getKind() != BuiltinType::Char32)) {
----------------
AaronBallman wrote:

> This means we’re not doing any promotion if the type is char16_t/char32_t, 
> which I don’t think is right, but @AaronBallman probably knows that better 
> than me.

Yeah, these should be promotable types by my reading of both the C and C++ 
standards.

> Also what do you think getCorrespondingSignedType(char16_t) should return? A 
> short or an int?

I think it should be a `short`; the default argument promotions are what should 
convert the type to an `int` when passing to a varargs call.

https://github.com/llvm/llvm-project/pull/195945
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to