Skip to content

Commit e3c1096

Browse files
vmaksimoFznamznon
andauthored
[sycl-post-link] Avoid copying from nullptr (#3963)
Co-authored-by: Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>
1 parent 0f7d1a6 commit e3c1096

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/tools/sycl-post-link/SpecConstants.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ void collectCompositeElementsDefaultValuesRecursive(
320320
} else { // Assume that we encountered some scalar element
321321
int NumBytes = Ty->getScalarSizeInBits() / CHAR_BIT +
322322
(Ty->getScalarSizeInBits() % 8 != 0);
323-
char *CharPtr;
323+
char *CharPtr = nullptr;
324324

325325
if (auto IntConst = dyn_cast<ConstantInt>(C)) {
326326
auto Val = IntConst->getValue().getZExtValue();
@@ -336,6 +336,7 @@ void collectCompositeElementsDefaultValuesRecursive(
336336
CharPtr = reinterpret_cast<char *>(&v);
337337
}
338338
}
339+
assert(CharPtr && "Unexpected constant type");
339340
std::copy_n(CharPtr, NumBytes, std::back_inserter(DefaultValues));
340341
Offset += NumBytes;
341342
}

0 commit comments

Comments
 (0)