[clang] [Clang] Fixed an assertion in constant evaluation of EmbedExpr inside array initializers. (PR #182257)
Aadarsh Keshri via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 22 12:22:24 PST 2026
Aadarsh-Keshri wrote:
I was able to eliminate ```Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"'``` assertion failure by changing the ```assert(DestTy->isFloatingType() && "unexpected type");``` to ```assert(DestTy->isRealFloatingType() && "unexpected type");```
In SemaInit, I tried replacing ```isScalarType``` with something like ```isIntgerType && !(isCompoundType || isPointerType)```. But that did fix anything.
I even tried to add a guard in ```canInitializeArrayWithEmbedDataString``` but even that did not fix anything:
```c
if (InitType->isArrayType()) {
const ArrayType *InitArrayType = InitType->getAsArrayTypeUnsafe();
auto ElementType = InitArrayType->getElementType();
if(!ElementType->isIntegerType())
return false;
StringLiteral *SL = EE->getDataStringLiteral();
return IsStringInit(SL, InitArrayType, Context) == SIF_None;
}
```
https://github.com/llvm/llvm-project/pull/182257
More information about the cfe-commits
mailing list