[clang] [clang] Fix for Assertion `(T->hasSignedIntegerRepresentation() || T->isSignedFixedPointType()) && "Unexpected signed integer or fixed point type"' failed. (PR #195945)
via cfe-commits
cfe-commits at lists.llvm.org
Thu May 7 05:18:11 PDT 2026
================
@@ -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)) {
----------------
Sirraide 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.
Also, I think this change should come with a codegen test to make sure we actually try to extract the right type from the va_list.
https://github.com/llvm/llvm-project/pull/195945
More information about the cfe-commits
mailing list