diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -4648,7 +4648,13 @@ InitDecl->getFlexibleArrayInitChars(getContext()); CharUnits CstSize = CharUnits::fromQuantity( getDataLayout().getTypeAllocSize(Init->getType())); - assert(VarSize == CstSize && "Emitted constant has unexpected size"); + // 'long double' is treated as 'double' in device code + const BuiltinType *BType = D->getType()->getAs(); + bool IsLongDouble = BType && BType->getKind() == BuiltinType::LongDouble; + bool IsDevice = getLangOpts().HIP || getLangOpts().CUDA || + getLangOpts().OpenMPIsDevice; + assert((VarSize == CstSize || (IsDevice && IsLongDouble)) && + "Emitted constant has unexpected size"); #endif } }