Add overflow check for array size (#3194)

Closes #3193
This commit is contained in:
Geoff Romer
2023-09-06 18:51:54 +00:00
committed by GitHub
parent cce013b43e
commit 6f02efe1d3
2 changed files with 49 additions and 1 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ auto HandleArrayExpression(Context& context, Parse::Node parse_node) -> bool {
if (bound_node.kind() == SemIR::NodeKind::IntegerLiteral) {
auto bound_value = context.semantics_ir().GetIntegerLiteral(
bound_node.GetAsIntegerLiteral());
if (!bound_value.isNegative()) {
if (!bound_value.isNegative() && bound_value.getBitWidth() <= 64) {
context.AddNodeAndPush(
parse_node,
SemIR::Node::ArrayType::Make(