[cfe-dev] Overflow(?) issue with ASTContext::getConstantArrayType
Francesco Bertolaccini via cfe-dev
cfe-dev at lists.llvm.org
Thu Dec 16 07:48:28 PST 2021
Hi everyone,
When using clang's API to generate C source code, I can create array
types of size up to 1 << 26, but anything more than that results in a
0-sized array:
// This works ok
auto type1 = ast_ctx.getConstantArrayType(
elm_type, llvm::APInt(64, 1ull << 26), nullptr,
clang::ArrayType::ArraySizeModifier::Normal, 0);
// This generates a 0-sized array type
auto type2 = ast_ctx.getConstantArrayType(
elm_type, llvm::APInt(64, 1ull << 27), nullptr,
clang::ArrayType::ArraySizeModifier::Normal, 0);
Is this a known bug or am I holding the API wrong?
Thanks,
Francesco
More information about the cfe-dev
mailing list